Move middleware to allow GET /health to work without authentication

This commit is contained in:
Melon 2025-01-27 21:57:09 +00:00
parent ad9d9e6b68
commit bd2f939fb1
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -76,12 +76,12 @@ func NewHttpServer(conf Conf, wd string) *http.Server {
}
r := http.NewServeMux()
r.Handle("/", handler)
r.Handle("GET /ok", http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
http.Error(rw, "Jasmine API Endpoint", http.StatusOK)
r.Handle("/", principle.Middleware(handler))
r.Handle("GET /health", http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
http.Error(rw, "Health OK", http.StatusOK)
}))
r.Handle("/.well-known/caldav", calHandler)
r.Handle("/{user}/calendar/", calHandler)
r.Handle("/.well-known/caldav", principle.Middleware(calHandler))
r.Handle("/{user}/calendar/", principle.Middleware(calHandler))
r2 := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
t := time.Now()
@ -92,7 +92,7 @@ func NewHttpServer(conf Conf, wd string) *http.Server {
return &http.Server{
Addr: conf.Listen,
Handler: principle.Middleware(r2),
Handler: r2,
ReadTimeout: time.Minute,
ReadHeaderTimeout: time.Minute,
WriteTimeout: time.Minute,