fix: restructure handler yet again #181

This commit is contained in:
2024-09-18 21:49:49 +02:00
parent 2f7081c0fe
commit a41265be98
4 changed files with 39 additions and 10 deletions

View File

@@ -7,9 +7,20 @@ import (
"net/http"
)
func handleWorkout(db *sql.DB, router *http.ServeMux) {
router.Handle("/workout", auth(db, service.HandleWorkoutPage(db)))
router.Handle("POST /api/workout", auth(db, service.HandleWorkoutNewComp(db)))
router.Handle("GET /api/workout", auth(db, service.HandleWorkoutGetComp(db)))
router.Handle("DELETE /api/workout/{id}", auth(db, service.HandleWorkoutDeleteComp(db)))
func workoutUi(db *sql.DB) http.Handler {
router := http.NewServeMux()
router.Handle("/workout", service.HandleWorkoutPage(db))
return router
}
func workoutApi(db *sql.DB) http.Handler {
router := http.NewServeMux()
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
}