Fix static path matching issue in macaron (#40023)

Co-authored-by: Malcolm Holmes <mdh@odoko.co.uk>
This commit is contained in:
Marcus Efraimsson
2021-10-05 19:38:09 +02:00
committed by GitHub
co-authored by Malcolm Holmes
parent feaa56a7fe
commit 329f96db1a
2 changed files with 16 additions and 4 deletions
+6 -4
View File
@@ -207,10 +207,12 @@ func (r *Router) NotFound(handlers ...Handler) {
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if t, ok := r.routers[req.Method]; ok {
// Fast match for static routes
leaf := r.getLeaf(req.Method, req.URL.Path)
if leaf != nil {
leaf.handle(rw, req, nil)
return
if !strings.ContainsAny(req.URL.Path, ":*") {
leaf := r.getLeaf(req.Method, req.URL.Path)
if leaf != nil {
leaf.handle(rw, req, nil)
return
}
}
h, p, ok := t.Match(req.URL.EscapedPath())