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.go
Tim 57893a4b85
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
Build and Push Docker Image / Explore-Gitea-Actions (push) Successful in 51s
chore: #123 unify metrics, logs, variable names and structure
2024-09-03 09:35:32 +02:00

32 lines
1.0 KiB
Go

package main
import (
"me-fit/middleware"
"me-fit/service"
"database/sql"
"net/http"
)
func getHandler(db *sql.DB) http.Handler {
var router = http.NewServeMux()
router.HandleFunc("/", service.HandleIndexAnd404(db))
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
router.HandleFunc("/workout", service.HandleWorkoutPage(db))
router.HandleFunc("POST /api/workout", service.HandleWorkoutNewComp(db))
router.HandleFunc("GET /api/workout", service.HandleWorkoutGetComp(db))
router.HandleFunc("DELETE /api/workout/{id}", service.HandleWorkoutDeleteComp(db))
router.HandleFunc("/auth/signin", service.HandleSignInPage(db))
router.HandleFunc("/auth/signup", service.HandleSignUpPage(db))
router.HandleFunc("/api/auth/signup", service.HandleSignUpComp(db))
router.HandleFunc("/api/auth/signin", service.HandleSignInComp(db))
router.HandleFunc("/api/auth/signout", service.HandleSignOutComp(db))
return middleware.Logging(middleware.EnableCors(router))
}