Skip to content

Commit 2ad06ce

Browse files
committed
Fixed #265
Signed-off-by: Vishal Rana <[email protected]>
1 parent 4f99641 commit 2ad06ce

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

echo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ var (
162162
// Errors
163163
//--------
164164

165-
UnsupportedMediaType = errors.New("echo ⇒ unsupported media type")
166-
RendererNotRegistered = errors.New("echo ⇒ renderer not registered")
167-
InvalidRedirectCode = errors.New("echo ⇒ invalid redirect status code")
165+
UnsupportedMediaType = errors.New("unsupported media type")
166+
RendererNotRegistered = errors.New("renderer not registered")
167+
InvalidRedirectCode = errors.New("invalid redirect status code")
168168

169169
//----------------
170170
// Error handlers

router.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@ func (n *node) findHandler(method string) HandlerFunc {
266266
}
267267
}
268268

269+
func (n *node) check405() HandlerFunc {
270+
for _, m := range methods {
271+
if h := n.findHandler(m); h != nil {
272+
return methodNotAllowedHandler
273+
}
274+
}
275+
return notFoundHandler
276+
}
277+
269278
func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo) {
270279
h = notFoundHandler
271280
e = r.echo
@@ -373,16 +382,19 @@ End:
373382
if cn.echo != nil {
374383
e = cn.echo
375384
}
385+
386+
// NOTE: Slow zone...
376387
if h == nil {
377-
h = methodNotAllowedHandler
388+
h = cn.check405()
389+
378390
// Dig further for match-any, might have an empty value for *, e.g.
379391
// serving a directory. Issue #207.
380392
if cn = cn.findChildByKind(mkind); cn == nil {
381393
return
382394
}
383395
ctx.pvalues[len(cn.pnames)-1] = ""
384396
if h = cn.findHandler(method); h == nil {
385-
h = methodNotAllowedHandler
397+
h = cn.check405()
386398
}
387399
}
388400
return

0 commit comments

Comments
 (0)