2024-08-28 10:55:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/go-chi/chi/v5/middleware"
|
|
|
|
"github.com/go-chi/cors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (app *Config) routes() http.Handler {
|
|
|
|
mux := chi.NewRouter()
|
|
|
|
|
|
|
|
// specify who is allowed to connect
|
|
|
|
mux.Use(cors.Handler(cors.Options{
|
|
|
|
AllowedOrigins: []string{"https://*", "http://*"},
|
|
|
|
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
|
|
|
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
|
|
|
ExposedHeaders: []string{"Link"},
|
|
|
|
AllowCredentials: true,
|
|
|
|
MaxAge: 300,
|
|
|
|
}))
|
|
|
|
|
|
|
|
mux.Use(middleware.Heartbeat("/ping"))
|
|
|
|
|
2024-08-28 18:54:54 +00:00
|
|
|
mux.Post("/authenticate", app.Authenticate)
|
|
|
|
|
2024-08-28 10:55:03 +00:00
|
|
|
return mux
|
|
|
|
}
|