fix: restructure handler yet again #181
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user