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/workout.go
Tim Wundenberg f184e261ee
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 47s
tbs
2024-09-17 22:47:54 +02:00

35 lines
756 B
Go

package handler
import (
"log/slog"
"me-fit/service"
"database/sql"
"net/http"
)
func workoutUi(db *sql.DB) http.Handler {
router := http.NewServeMux()
router.Handle("/workout", service.HandleWorkoutPage(db))
router.Handle("/", service.HandleIndexAnd404(db))
return router
}
func workoutApi(db *sql.DB) http.Handler {
router := http.NewServeMux()
// root = "/api/workout/"
router.Handle("POST /api/workout", service.HandleWorkoutNewComp(db))
router.Handle("GET /api/workout", service.HandleWorkoutGetComp(db))
router.Handle("DELETE /api/workout/{id}", service.HandleWorkoutDeleteComp(db))
// return router
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
slog.Warn(r.URL.Path)
router.ServeHTTP(w, r)
})
}