fix: restructure env handling for better testing capabillities #181
This commit was merged in pull request #195.
This commit is contained in:
@@ -4,26 +4,27 @@ import (
|
||||
"me-fit/db"
|
||||
"me-fit/middleware"
|
||||
"me-fit/service"
|
||||
"me-fit/types"
|
||||
|
||||
"database/sql"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetHandler(d *sql.DB) http.Handler {
|
||||
func GetHandler(d *sql.DB, serverSettings *types.ServerSettings) http.Handler {
|
||||
var router = http.NewServeMux()
|
||||
|
||||
router.HandleFunc("/", service.HandleIndexAnd404(d))
|
||||
router.HandleFunc("/", service.HandleIndexAnd404(d, serverSettings))
|
||||
|
||||
handlerAuth := NewHandlerAuth(d, service.NewServiceAuthImpl(db.NewDbAuthSqlite(d)))
|
||||
handlerAuth := NewHandlerAuth(d, service.NewServiceAuthImpl(db.NewDbAuthSqlite(d)), serverSettings)
|
||||
|
||||
// Serve static files (CSS, JS and images)
|
||||
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
|
||||
|
||||
handleWorkout(d, router)
|
||||
handleWorkout(d, router, serverSettings)
|
||||
|
||||
handlerAuth.handle(router)
|
||||
|
||||
return middleware.Logging(middleware.EnableCors(router))
|
||||
return middleware.Logging(middleware.EnableCors(serverSettings, router))
|
||||
}
|
||||
|
||||
func auth(db *sql.DB, h http.Handler) http.Handler {
|
||||
|
||||
Reference in New Issue
Block a user