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 9c7d7e2cb3
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
#109 switch svelte to SSR with go
2024-08-24 22:08:58 +02:00

26 lines
663 B
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)
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
router.HandleFunc("/app", service.App)
router.HandleFunc("POST /api/workout", service.NewWorkout(db))
router.HandleFunc("GET /api/workout", service.GetWorkouts(db))
router.HandleFunc("DELETE /api/workout", service.DeleteWorkout(db))
return middleware.Logging(middleware.EnableCors(router))
}