Skip to content

Commit

Permalink
Add database pool to ShioriServer struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Orhideous committed Aug 8, 2022
1 parent cac8872 commit c614ce0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions internal/api/server.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package api

import "github.com/go-shiori/shiori/internal/database"

// ShioriServer holds configuration and connection pools
type ShioriServer struct{}
type ShioriServer struct {
DB database.DB
}

// NewShioriServer creates new API server
func NewShioriServer() *ShioriServer {
return &ShioriServer{}
func NewShioriServer(db database.DB) *ShioriServer {
return &ShioriServer{
DB: db,
}
}
4 changes: 3 additions & 1 deletion internal/webserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ func ServeApp(cfg Config) error {
swagger.Servers = nil

// Create server
shioriServer := api.NewShioriServer()
shioriServer := api.NewShioriServer(
cfg.DB,
)

// Leave all legacy API as-is
e.Any("/*", echo.WrapHandler(router))
Expand Down

0 comments on commit c614ce0

Please sign in to comment.