fix: restructure handler yet again #181
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 45s

This commit is contained in:
2024-09-17 22:47:54 +02:00
parent 2f7081c0fe
commit 3136f587eb
5 changed files with 79 additions and 10 deletions

View File

@@ -16,11 +16,17 @@ func GetHandler(db *sql.DB) http.Handler {
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
handleWorkout(db, router)
router.Handle("/auth/", authUi(db))
router.Handle("/api/auth/", authApi(db))
handleAuth(db, router)
router.Handle("/workout", auth(db, workoutUi(db)))
router.Handle("/api/workout", auth(db, workoutApi(db)))
// Needed a second time with trailing slash, otherwise either /api/workout or /api/workout/{id} does not match
router.Handle("/api/workout/", auth(db, workoutApi(db)))
return middleware.Logging(middleware.EnableCors(router))
return middleware.Logging(
middleware.EnableCors(
router))
}
func auth(db *sql.DB, h http.Handler) http.Handler {