func trailingSlashMiddleware()

in pkg/server/httpserver.go [172:180]


func trailingSlashMiddleware(pathHandler http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		// support "/" as a valid path
		if r.URL.Path != "/" && strings.HasSuffix(r.URL.Path, "/") {
			r.URL.Path = strings.TrimSuffix(r.URL.Path, "/")
		}
		pathHandler.ServeHTTP(w, r)
	})
}