worker/v1: rearrange middlewares

The duration middleware should come after the tenant channel middleware,
otherwise the tenant in the context will be empty. The status middleware
can come beforehand because it queries the request context right before
sending a response.
This commit is contained in:
Sanne Raymaekers 2023-06-29 14:32:22 +02:00
parent f303e7c233
commit 6040c10e10

View file

@ -102,11 +102,11 @@ func (s *Server) Handler() http.Handler {
mws := []echo.MiddlewareFunc{
prometheus.StatusMiddleware(prometheus.WorkerSubsystem),
prometheus.HTTPDurationMiddleware(prometheus.WorkerSubsystem),
}
if s.config.JWTEnabled {
mws = append(mws, auth.TenantChannelMiddleware(s.config.TenantProviderFields, api.HTTPError(api.ErrorTenantNotFound)))
}
mws = append(mws, prometheus.HTTPDurationMiddleware(prometheus.WorkerSubsystem))
api.RegisterHandlers(e.Group(api.BasePath, mws...), &handler)
return e