fix: more refactoring #181
Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 2m8s

This commit is contained in:
2024-10-12 21:57:39 +02:00
parent 0fab1e1f2e
commit d3ff302d3e
13 changed files with 779 additions and 561 deletions

View File

@@ -13,15 +13,17 @@ import (
func GetHandler(d *sql.DB, serverSettings *types.ServerSettings) http.Handler {
var router = http.NewServeMux()
router.HandleFunc("/", service.HandleIndexAnd404(d, serverSettings))
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/"))))
@@ -31,7 +33,3 @@ func GetHandler(d *sql.DB, serverSettings *types.ServerSettings) http.Handler {
return middleware.Logging(middleware.EnableCors(serverSettings, router))
}
func authMiddleware(db *sql.DB, h http.Handler) http.Handler {
return middleware.EnsureValidSession(db, h)
}