mirror of
https://github.com/labstack/echo.git
synced 2024-11-24 08:22:21 +02:00
parent
4f996419e1
commit
2ad06ce67e
6
echo.go
6
echo.go
@ -162,9 +162,9 @@ var (
|
||||
// Errors
|
||||
//--------
|
||||
|
||||
UnsupportedMediaType = errors.New("echo ⇒ unsupported media type")
|
||||
RendererNotRegistered = errors.New("echo ⇒ renderer not registered")
|
||||
InvalidRedirectCode = errors.New("echo ⇒ invalid redirect status code")
|
||||
UnsupportedMediaType = errors.New("unsupported media type")
|
||||
RendererNotRegistered = errors.New("renderer not registered")
|
||||
InvalidRedirectCode = errors.New("invalid redirect status code")
|
||||
|
||||
//----------------
|
||||
// Error handlers
|
||||
|
16
router.go
16
router.go
@ -266,6 +266,15 @@ func (n *node) findHandler(method string) HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (n *node) check405() HandlerFunc {
|
||||
for _, m := range methods {
|
||||
if h := n.findHandler(m); h != nil {
|
||||
return methodNotAllowedHandler
|
||||
}
|
||||
}
|
||||
return notFoundHandler
|
||||
}
|
||||
|
||||
func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo) {
|
||||
h = notFoundHandler
|
||||
e = r.echo
|
||||
@ -373,8 +382,11 @@ End:
|
||||
if cn.echo != nil {
|
||||
e = cn.echo
|
||||
}
|
||||
|
||||
// NOTE: Slow zone...
|
||||
if h == nil {
|
||||
h = methodNotAllowedHandler
|
||||
h = cn.check405()
|
||||
|
||||
// Dig further for match-any, might have an empty value for *, e.g.
|
||||
// serving a directory. Issue #207.
|
||||
if cn = cn.findChildByKind(mkind); cn == nil {
|
||||
@ -382,7 +394,7 @@ End:
|
||||
}
|
||||
ctx.pvalues[len(cn.pnames)-1] = ""
|
||||
if h = cn.findHandler(method); h == nil {
|
||||
h = methodNotAllowedHandler
|
||||
h = cn.check405()
|
||||
}
|
||||
}
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user