fix: restructure handler.go #181
This commit was merged in pull request #182.
This commit is contained in:
28
handler/default.go
Normal file
28
handler/default.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"me-fit/middleware"
|
||||
"me-fit/service"
|
||||
|
||||
"database/sql"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetHandler(db *sql.DB) http.Handler {
|
||||
var router = http.NewServeMux()
|
||||
|
||||
router.HandleFunc("/", service.HandleIndexAnd404(db))
|
||||
|
||||
// Serve static files (CSS, JS and images)
|
||||
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
|
||||
|
||||
handleWorkout(db, router)
|
||||
|
||||
handleAuth(db, router)
|
||||
|
||||
return middleware.Logging(middleware.EnableCors(router))
|
||||
}
|
||||
|
||||
func auth(db *sql.DB, h http.Handler) http.Handler {
|
||||
return middleware.EnsureValidSession(db, h)
|
||||
}
|
||||
Reference in New Issue
Block a user