Closed
Description
Issue Description
For match any routes configured on multiple levels the wrong route seems to be chosen.
It is expected that if a route is not found, that the nearest (longest matching) match any route is chosen.
For the following defined routes
/api/user
/api/*
/*
it would be expected for any request under /api
that can not be resolved to return the match any /api/*
route, even those under /api/user/something
.
This is currently handled for static only routes that way.
A PR will be opened to resolve this issue (probably alongside with #1406).
Checklist
- Dependencies installed
- No typos
- Searched existing issues and docs
Expected behaviour
The route /api/* will be chosen
Actual behaviour
A not found is returned for /api/user/notexists
Steps to reproduce
Run example below.
Working code to debug
package main
import (
"net/http"
"github.com/labstack/echo/v4"
)
func main() {
// Echo instance
e := echo.New()
// Routes
e.GET("/admin", func(c echo.Context) error { return c.String(http.StatusOK, "admin") })
e.GET("/api/help", func(c echo.Context) error { return c.String(http.StatusOK, "api help") })
e.GET("/api/*", func(c echo.Context) error { return c.String(http.StatusOK, "api any") })
e.GET("/*", func(c echo.Context) error { return c.String(http.StatusOK, "root any") })
// Start server
e.Logger.Fatal(e.Start(":1323"))
}
Version/commit
Tested with v4.1.10
Metadata
Metadata
Assignees
Labels
No labels