-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The 'RouteNotFound' have a bug #2401
Comments
Hi, I am unable to recreate it. Could you edit my example: func main() {
e := echo.New()
e.HTTPErrorHandler = func(err error, c echo.Context) {
log.Printf("--- inside global error handler!\n")
e.DefaultHTTPErrorHandler(err, c)
}
e.GET("/test1", hello)
e.GET("/test2", hello)
e.RouteNotFound("/*", indexHandler)
g := e.Group("/admin")
g.GET("/test1", hello)
g.GET("/test2", hello)
g.RouteNotFound("/*", adminIndexHandler)
if err := e.Start(":8080"); !errors.Is(err, http.ErrServerClosed) {
log.Fatal(err)
}
}
func hello(c echo.Context) error {
log.Printf("=== inside hello handler!\n")
return c.String(http.StatusOK, "hello!")
}
func indexHandler(c echo.Context) error {
log.Printf("+++ inside indexHandler handler!\n")
return c.String(http.StatusOK, "indexHandler!")
}
func adminIndexHandler(c echo.Context) error {
log.Printf("--- inside adminIndexHandler handler!\n")
return c.String(http.StatusOK, "adminIndexHandler!")
// if this functions returns an error the `e.HTTPErrorHandler` fill handle it
} I test with Output: x@x:~/codet$ curl -v http://localhost:8080/admin/test3
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /admin/test3 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.85.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=UTF-8
< Date: Sat, 18 Feb 2023 16:26:41 GMT
< Content-Length: 18
<
* Connection #0 to host localhost left intact
adminIndexHandler! |
@aldas hi, i test and find the bug. When use |
@aldas hi,i test and the bug is come when have a middle. example: |
This will be fixed with #2411 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue Description
Checklist
Expected behaviour
Actual behaviour
Steps to reproduce
Working code to debug
Version/commit
Get path
/test3
and will gotoindexHandler
, bug get/admin/test3
gotoHTTPErrorHandler
. The/admin/test3
gotoadminIndexHandler
is right.The
echo
code have some test, but the bug is not checked.The text was updated successfully, but these errors were encountered: