#73 change authorization

This commit is contained in:
2024-08-25 22:25:32 +02:00
parent 81548465e7
commit d854dae68f
19 changed files with 589 additions and 187 deletions

View File

@@ -11,15 +11,21 @@ import (
func getHandler(db *sql.DB) http.Handler {
var router = http.NewServeMux()
router.HandleFunc("/", service.HandleIndexAnd404)
router.HandleFunc("/", service.HandleIndexAnd404(db))
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
router.HandleFunc("/app", service.App)
router.HandleFunc("POST /api/workout", service.NewWorkout(db))
router.HandleFunc("GET /api/workout", service.GetWorkouts(db))
router.HandleFunc("DELETE /api/workout", service.DeleteWorkout(db))
router.HandleFunc("/app", service.HandleWorkoutPage(db))
router.HandleFunc("POST /api/workout", service.HandleNewWorkout(db))
router.HandleFunc("GET /api/workout", service.HandleGetWorkouts(db))
router.HandleFunc("DELETE /api/workout/{id}", service.HandleDeleteWorkout(db))
router.HandleFunc("/auth/signin", service.HandleSignInPage(db))
router.HandleFunc("/auth/signup", service.HandleSignUpPage(db))
router.HandleFunc("/api/auth/signup", service.HandleSignUp(db))
router.HandleFunc("/api/auth/signin", service.HandleSignIn(db))
router.HandleFunc("/api/auth/signout", service.HandleSignOutComp(db))
return middleware.Logging(middleware.EnableCors(router))
}