feat: update some errorhandling #161

This commit is contained in:
2024-09-10 12:13:10 +02:00
parent 37c3b2a780
commit 80ab17276e
7 changed files with 99 additions and 45 deletions

View File

@@ -13,6 +13,10 @@ import (
func getHandler(db *sql.DB) http.Handler {
var router = http.NewServeMux()
if utils.Environment == "dev" {
router.HandleFunc("/mail/", handleMails)
}
router.HandleFunc("/", service.HandleIndexAnd404(db))
// Serve static files (CSS, JS and images)
@@ -33,19 +37,15 @@ func getHandler(db *sql.DB) http.Handler {
router.Handle("/api/auth/signout", service.HandleSignOutComp(db))
router.Handle("/api/auth/verify-resend", service.HandleVerifyResendComp(db))
if utils.Environment == "dev" {
router.HandleFunc("/mail/", handleMails)
}
return middleware.Logging(middleware.EnableCors(router))
}
func auth(db *sql.DB, h http.Handler) http.Handler {
return middleware.EnsureValidSession(db, h)
}
func handleMails(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/mail/register" {
mail.Register("test-code").Render(r.Context(), w)
}
}
func auth(db *sql.DB, h http.Handler) http.Handler {
return middleware.EnsureValidSession(db, h)
}