All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 47s
35 lines
756 B
Go
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)
|
|
})
|
|
}
|