1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-28 08:38:39 +02:00
echo/middleware
Tom Scholz 31361576e8 feat: Add a new ErrorHandlerWithContext (#1328)
* feat: Add a new ErrorHandlerWithContext

This commit adds a new error handler, which is passed the 
current context, so that you can add custom redirects or even
other kinds of responses. For example:

```go
	e.Use(middleware.JWTWithConfig(middleware.JWTConfig{
		SigningKey: []byte("secret"),
		TokenLookup: "query:token",
		ErrorHandlerWithContext: func(err error, c echo.Context) error {
			// do stuff with context and err
			switch err.(type) {
			case jwt.ValidationError:
				return c.Redirect(http.StatusSeeOther, "/login")
			}
			return err
		},
	}))
```

* chore: address golint issues
2019-06-13 13:21:03 -07:00
..
basic_auth_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
basic_auth.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
body_dump_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
body_dump.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
body_limit_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
body_limit.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
compress_test.go Fix flushing in Gzip middleware (#1317) 2019-04-16 15:52:06 -05:00
compress.go Fix flushing in Gzip middleware (#1317) 2019-04-16 15:52:06 -05:00
cors_test.go Set subdomains to AllowOrigins with wildcard (#1301) 2019-03-09 10:32:49 -08:00
cors.go Set subdomains to AllowOrigins with wildcard (#1301) 2019-03-09 10:32:49 -08:00
csrf_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
csrf.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
jwt_test.go Added param:<name> lookup option to JWT Middleware (#1296) 2019-06-09 09:49:52 -07:00
jwt.go feat: Add a new ErrorHandlerWithContext (#1328) 2019-06-13 13:21:03 -07:00
key_auth_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
key_auth.go Fixed #1323 2019-06-09 09:37:21 -07:00
logger_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
logger.go Fixed invalid json value for error in logger middleware 2019-04-29 13:21:11 -07:00
method_override_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
method_override.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
middleware.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
proxy_1_11_n.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
proxy_1_11_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
proxy_1_11.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
proxy_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
proxy.go Refactor DefaultProxyConfig Skipper & WebSocket Check in Context (#1297) 2019-03-02 10:43:23 -08:00
recover_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
recover.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
redirect_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
redirect.go www redirects are too broad (#1274) 2019-02-15 09:56:58 -08:00
request_id_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
request_id.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
rewrite_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
rewrite.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
secure_test.go Enable adding preload tag to HSTS header (#1247) 2019-03-06 10:22:19 -08:00
secure.go Enable adding preload tag to HSTS header (#1247) 2019-03-06 10:22:19 -08:00
slash_test.go Simplify code of Add/Remove trailing slash and fix bug (#1275) 2019-02-07 09:49:51 -08:00
slash.go Simplify code of Add/Remove trailing slash and fix bug (#1275) 2019-02-07 09:49:51 -08:00
static_test.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
static.go Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism 2019-01-30 16:11:42 +02:00
util_test.go Set subdomains to AllowOrigins with wildcard (#1301) 2019-03-09 10:32:49 -08:00
util.go Set subdomains to AllowOrigins with wildcard (#1301) 2019-03-09 10:32:49 -08:00