Browse Source

Fix landing when non-empty path prefix is set

DarthSim 1 year ago
parent
commit
c3466c4ac1
2 changed files with 8 additions and 0 deletions
  1. 5 0
      router/router.go
  2. 3 0
      server.go

+ 5 - 0
router/router.go

@@ -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},

+ 3 - 0
server.go

@@ -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)