diff --git a/pkg/srv/http/http.go b/pkg/srv/http/http.go index 456fb9a..16a7cae 100644 --- a/pkg/srv/http/http.go +++ b/pkg/srv/http/http.go @@ -7,6 +7,7 @@ import ( "net" "net/http" "os" + "strings" "time" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -60,6 +61,13 @@ func prepHTTPServer(opts *opts.AppHTTP) *http.Server { // Inject extra handlers if given // Used for grpc-gateway runtime.ServeMux handlers for _, h := range opts.Handlers { + // prefix must end in / to route sub-paths + if !strings.HasSuffix(h.Prefix, "/") { + h.Prefix = h.Prefix + "/" + } + + // if enabled, the path prefix is stripped before + // requests are sent to the handler if h.StripPrefix { h.Handler = http.StripPrefix(h.Prefix, h.Handler) }