1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Exposed error handlers

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-07-05 08:43:46 -07:00
parent c00d017178
commit 451b2ccc9f
4 changed files with 7 additions and 7 deletions

View File

@ -508,5 +508,5 @@ func (c *echoContext) Reset(req engine.Request, res engine.Response) {
c.context = context.Background()
c.request = req
c.response = res
c.handler = notFoundHandler
c.handler = NotFoundHandler
}

View File

@ -209,11 +209,11 @@ var (
// Error handlers
var (
notFoundHandler = func(c Context) error {
NotFoundHandler = func(c Context) error {
return ErrNotFound
}
methodNotAllowedHandler = func(c Context) error {
MethodNotAllowedHandler = func(c Context) error {
return ErrMethodNotAllowed
}
)
@ -243,7 +243,7 @@ func (e *Echo) NewContext(req engine.Request, res engine.Response) Context {
response: res,
echo: e,
pvalues: make([]string, *e.maxParam),
handler: notFoundHandler,
handler: NotFoundHandler,
}
}

View File

@ -129,7 +129,7 @@ func TestEchoMiddlewareError(t *testing.T) {
e.Use(WrapMiddleware(func(c Context) error {
return errors.New("error")
}))
e.GET("/", notFoundHandler)
e.GET("/", NotFoundHandler)
c, _ := request(GET, "/", e)
assert.Equal(t, http.StatusInternalServerError, c)
}

View File

@ -272,10 +272,10 @@ func (n *node) findHandler(method string) HandlerFunc {
func (n *node) checkMethodNotAllowed() HandlerFunc {
for _, m := range methods {
if h := n.findHandler(m); h != nil {
return methodNotAllowedHandler
return MethodNotAllowedHandler
}
}
return notFoundHandler
return NotFoundHandler
}
// Find lookup a handler registed for method and path. It also parses URL for path