godash/handlers/routes.go

23 lines
710 B
Go
Raw Normal View History

2024-03-12 15:49:08 +01:00
package handlers
import (
"net/http"
"github.com/r3labs/sse/v2"
)
func SetupRoutes(router *http.ServeMux, sse *sse.Server, appHandler *AppHandler, authHandler *AuthHandler) {
if authHandler.oidc != nil {
router.Handle("/auth/", authHandler.oidc)
2024-03-19 11:36:09 +01:00
}
router.Handle("/sse", authHandler.mw.RequireAuthentication()(http.HandlerFunc(sse.ServeHTTP)))
2024-03-19 11:36:09 +01:00
fsAssets := http.FileServer(http.Dir("assets"))
router.Handle("/assets/", http.StripPrefix("/assets/", fsAssets))
2024-03-12 15:49:08 +01:00
fsIcons := http.FileServer(http.Dir("storage/icons"))
router.Handle("/storage/icons/", http.StripPrefix("/storage/icons/", fsIcons))
2024-03-12 15:49:08 +01:00
router.Handle("/", authHandler.mw.RequireAuthentication()(http.HandlerFunc(appHandler.appHandler)))
2024-03-12 15:49:08 +01:00
}