Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 2m8s
36 lines
972 B
Go
36 lines
972 B
Go
package handler
|
|
|
|
import (
|
|
"me-fit/db"
|
|
"me-fit/middleware"
|
|
"me-fit/service"
|
|
"me-fit/types"
|
|
|
|
"database/sql"
|
|
"net/http"
|
|
)
|
|
|
|
func GetHandler(d *sql.DB, serverSettings *types.ServerSettings) http.Handler {
|
|
var router = http.NewServeMux()
|
|
|
|
randomGenerator := service.NewRandomGeneratorImpl()
|
|
clock := service.NewClockImpl()
|
|
dbAuth := db.NewDbAuthSqlite(d)
|
|
mailService := service.NewMailServiceImpl(serverSettings)
|
|
serviceAuth := service.NewServiceAuthImpl(dbAuth, randomGenerator, clock, mailService, serverSettings)
|
|
|
|
handlerIndex := NewHandlerIndex(d, serviceAuth, serverSettings)
|
|
handlerAuth := NewHandlerAuth(d, serviceAuth, serverSettings)
|
|
|
|
handlerIndex.handle(router)
|
|
|
|
// Serve static files (CSS, JS and images)
|
|
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
|
|
|
|
handleWorkout(d, router, serverSettings)
|
|
|
|
handlerAuth.handle(router)
|
|
|
|
return middleware.Logging(middleware.EnableCors(serverSettings, router))
|
|
}
|