feat: update some errorhandling #161
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:
16
handler.go
16
handler.go
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user