grafana/pkg/middleware
sh0rez 534ece064b
pkg/web: closure-style middlewares (#51238)
* pkg/web: closure-style middlewares

Switches the middleware execution model from web.Handlers in a slice to
web.Middleware.
Middlewares are temporarily kept in a slice to preserve ordering, but
prior to execution they are applied, forming a giant call-stack, giving
granular control over the execution flow.

* pkg/middleware: adapt to web.Middleware

* pkg/middleware/recovery: use c.Req over req

c.Req gets updated by future handlers, while req stays static.

The current recovery implementation needs this newer information

* pkg/web: correct middleware ordering

* pkg/webtest: adapt middleware

* pkg/web/hack: set w and r onto web.Context

By adopting std middlewares, it may happen they invoke next(w,r) without
putting their modified w,r into the web.Context, leading old-style
handlers to operate on outdated fields.

pkg/web now takes care of this

* pkg/middleware: selectively use future context

* pkg/web: accept closure-style on Use()

* webtest: Middleware testing

adds a utility function to web/webtest to obtain a http.ResponseWriter,
http.Request and http.Handler the same as a middleware that runs would receive

* *: cleanup

* pkg/web: don't wrap Middleware from Router

* pkg/web: require chain to write response

* *: remove temp files

* webtest: don't require chain write

* *: cleanup
2022-08-09 14:58:50 +02:00
..
cookies Backend: Remove more globals (#29644) 2020-12-15 19:09:04 +01:00
csrf CSRF: Fix additional headers option (#50629) 2022-07-13 19:28:59 +01:00
auth_test.go Chore: Remove bus from contexthandler (#47374) 2022-04-06 16:31:26 +02:00
auth.go Access Control: Allow dashboard admins to query org users (#51652) 2022-07-04 10:43:06 +01:00
csp.go Macaron: convert CSP middleware (#37672) 2021-08-10 09:03:22 +02:00
dashboard_redirect_test.go Chore: Remove endpoints that contain the slug field (#35104) 2021-06-03 16:20:13 +03:00
dashboard_redirect.go Chore: Remove endpoints that contain the slug field (#35104) 2021-06-03 16:20:13 +03:00
gziper.go Chore: replace macaron with web package (#40136) 2021-10-11 14:30:59 +02:00
logger_test.go Auth: Implement Token URL JWT Auth (#52662) 2022-07-27 16:10:47 +02:00
logger.go pkg/web: closure-style middlewares (#51238) 2022-08-09 14:58:50 +02:00
middleware_basic_auth_test.go Chore: Move api key models into apikey service package (#53241) 2022-08-04 14:19:09 +02:00
middleware_jwt_auth_test.go Chore: Move user errors to user service (#52460) 2022-07-20 14:50:06 +02:00
middleware_test.go pkg/web: closure-style middlewares (#51238) 2022-08-09 14:58:50 +02:00
middleware.go Middleware: Don't require HTTPS for HSTS headers to be emitted (#35147) 2022-01-28 07:23:28 +01:00
org_redirect_test.go Chore: Remove bus (#47511) 2022-04-08 16:15:06 +02:00
org_redirect.go Chore: Remove bus from contexthandler (#47458) 2022-04-08 10:33:19 +02:00
quota_test.go Add delete user from other services/stores (#51912) 2022-07-15 18:06:44 +02:00
quota.go Chore: Remove bus from quota (#45143) 2022-02-10 12:42:06 +01:00
rate_limit_test.go Chore: split APIKey store (#52781) 2022-08-02 16:55:19 +02:00
rate_limit.go Chore: replace macaron with web package (#40136) 2021-10-11 14:30:59 +02:00
recovery_test.go pkg/web: closure-style middlewares (#51238) 2022-08-09 14:58:50 +02:00
recovery.go pkg/web: closure-style middlewares (#51238) 2022-08-09 14:58:50 +02:00
request_metrics.go pkg/web: closure-style middlewares (#51238) 2022-08-09 14:58:50 +02:00
request_test.go Instrumentation: Define handlers for requests that are not handled with named handlers (#50613) 2022-06-14 07:58:20 +02:00
request_tracing.go pkg/web: closure-style middlewares (#51238) 2022-08-09 14:58:50 +02:00
testing.go Chore: split APIKey store (#52781) 2022-08-02 16:55:19 +02:00
validate_host.go Chore: replace macaron with web package (#40136) 2021-10-11 14:30:59 +02:00