Fix landing when non-empty path prefix is set

This commit is contained in:
DarthSim
2024-01-25 19:07:34 +03:00
parent 11c6de9950
commit c3466c4ac1
2 changed files with 8 additions and 0 deletions

View File

@@ -65,6 +65,11 @@ func New(prefix string) *Router {
}
func (r *Router) Add(method, prefix string, handler RouteHandler, exact bool) {
// Don't add routes with empty prefix
if len(r.prefix+prefix) == 0 {
return
}
r.Routes = append(
r.Routes,
&route{Method: method, Prefix: r.prefix + prefix, Handler: handler, Exact: exact},

View File

@@ -30,7 +30,10 @@ func buildRouter() *router.Router {
r := router.New(config.PathPrefix)
r.GET("/", handleLanding, true)
r.GET("", handleLanding, true)
r.GET("/", withMetrics(withPanicHandler(withCORS(withSecret(handleProcessing)))), false)
r.HEAD("/", withCORS(handleHead), false)
r.OPTIONS("/", withCORS(handleHead), false)