godash/handlers/routes.go

23 lines
786 B
Go
Raw Normal View History

2024-03-12 15:49:08 +01:00
package handlers
import (
"net/http"
"github.com/r3labs/sse/v2"
)
2024-09-10 19:46:16 +02:00
func SetupRoutes(router *http.ServeMux, sse *sse.Server, appHandler *AppHandler, authHandler *AuthHandler) {
2024-09-16 11:45:24 +02:00
router.Handle("GET /sse", authHandler.AuthMiddleware(http.HandlerFunc(sse.ServeHTTP)))
2024-04-12 16:19:11 +02:00
2024-05-21 17:33:13 +02:00
fsAssets := http.FileServer(http.Dir("assets"))
router.Handle("GET /assets/", authHandler.AuthMiddleware(http.StripPrefix("/assets/", fsAssets)))
2024-04-12 16:19:11 +02:00
2024-06-11 19:08:02 +02:00
icons := http.FileServer(http.Dir("storage/icons"))
router.Handle("GET /icons/", authHandler.AuthMiddleware(http.StripPrefix("/icons/", icons)))
2024-06-11 19:08:02 +02:00
2024-09-25 15:33:28 +02:00
router.HandleFunc("GET /logout", authHandler.handleLogout)
router.HandleFunc("GET /callback", authHandler.handleCallback)
2024-09-10 19:46:16 +02:00
2024-09-16 06:55:39 +02:00
router.Handle("GET /", authHandler.AuthMiddleware(http.HandlerFunc(appHandler.appHandler)))
2024-03-12 15:49:08 +01:00
}