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 ec0e748e1f
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 45s
chore: extract mail to it's own service
2024-09-27 23:21:37 +02:00

32 lines
712 B
Go

package handler
import (
"me-fit/db"
"me-fit/middleware"
"me-fit/service"
"database/sql"
"net/http"
)
func GetHandler(d *sql.DB) http.Handler {
var router = http.NewServeMux()
router.HandleFunc("/", service.HandleIndexAnd404(d))
handlerAuth := NewHandlerAuth(d, service.NewServiceAuthImpl(db.NewDbAuthSqlite(d), service.NewServiceMail()))
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
handleWorkout(d, router)
handlerAuth.handle(router)
return middleware.Logging(middleware.EnableCors(router))
}
func auth(db *sql.DB, h http.Handler) http.Handler {
return middleware.EnsureValidSession(db, h)
}