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 cbf5b39294
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 47s
Build and Push Docker Image / Explore-Gitea-Actions (push) Successful in 51s
fix: move signin handler #181
2024-10-03 23:24:58 +02:00

33 lines
814 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()
router.HandleFunc("/", service.HandleIndexAnd404(d, serverSettings))
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, serverSettings)
handlerAuth.handle(router)
return middleware.Logging(middleware.EnableCors(serverSettings, router))
}
func authMiddleware(db *sql.DB, h http.Handler) http.Handler {
return middleware.EnsureValidSession(db, h)
}