chore(auth): more refactoring
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
This commit is contained in:
@@ -21,17 +21,17 @@ func GetHandler(db *sql.DB) http.Handler {
|
||||
router.Handle("/auth/", authUi(db))
|
||||
router.Handle("/api/auth/", authApi(db))
|
||||
|
||||
router.Handle("/workout", auth(db, workoutUi(db)))
|
||||
router.Handle("/api/workout", auth(db, workoutApi(db)))
|
||||
router.Handle("/workout", authMiddleware(db, workoutUi(db)))
|
||||
router.Handle("/api/workout", authMiddleware(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)))
|
||||
router.Handle("/api/workout/", authMiddleware(db, workoutApi(db)))
|
||||
|
||||
return middleware.Logging(
|
||||
middleware.EnableCors(
|
||||
router))
|
||||
}
|
||||
|
||||
func auth(db *sql.DB, h http.Handler) http.Handler {
|
||||
func authMiddleware(db *sql.DB, h http.Handler) http.Handler {
|
||||
return middleware.EnsureValidSession(db, h)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user