This repository has been archived on 2025-08-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
web-app-template/handler.go
Tim 89bc723427
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s
Build and Push Docker Image / Explore-Gitea-Actions (push) Successful in 52s
feat(mail): #132 unify env variables and send mails with smtp
2024-09-06 19:09:25 +02:00

37 lines
1.2 KiB
Go

package main
import (
"me-fit/middleware"
"me-fit/service"
"me-fit/utils"
"database/sql"
"net/http"
)
func getHandler(db *sql.DB) http.Handler {
var router = http.NewServeMux()
router.HandleFunc("/", service.HandleIndexAnd404(db))
router.HandleFunc("/mail", func(w http.ResponseWriter, r *http.Request) {
utils.SendWelcomeMail("timwundenberg@outlook.de")
})
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
router.HandleFunc("/workout", service.HandleWorkoutPage(db))
router.HandleFunc("POST /api/workout", service.HandleWorkoutNewComp(db))
router.HandleFunc("GET /api/workout", service.HandleWorkoutGetComp(db))
router.HandleFunc("DELETE /api/workout/{id}", service.HandleWorkoutDeleteComp(db))
router.HandleFunc("/auth/signin", service.HandleSignInPage(db))
router.HandleFunc("/auth/signup", service.HandleSignUpPage(db))
router.HandleFunc("/api/auth/signup", service.HandleSignUpComp(db))
router.HandleFunc("/api/auth/signin", service.HandleSignInComp(db))
router.HandleFunc("/api/auth/signout", service.HandleSignOutComp(db))
return middleware.Logging(middleware.EnableCors(router))
}