This repository has been archived on 2025-08-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
web-app-template/handler/default.go
Tim Wundenberg cf96c9be5b
Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 1m43s
fix: more refactoring #181
2024-10-20 15:02:39 +02:00

39 lines
1.2 KiB
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)
dbWorkout := db.NewDbWorkoutSqlite(d)
mailService := service.NewMailServiceImpl(serverSettings)
serviceAuth := service.NewServiceAuthImpl(dbAuth, randomGenerator, clock, mailService, serverSettings)
serviceWorkout := service.NewServiceWorkoutImpl(dbWorkout, randomGenerator, clock, mailService, serverSettings)
handlerIndex := NewHandlerIndex(d, serviceAuth, serverSettings)
handlerAuth := NewHandlerAuth(d, serviceAuth, serverSettings)
handlerWorkout := NewHandlerWorkout(d, serviceWorkout, serviceAuth, serverSettings)
handlerIndex.handle(router)
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
handlerWorkout.handle(router)
handlerAuth.handle(router)
return middleware.Logging(middleware.EnableCors(serverSettings, router))
}