cloudapi/v2: 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:31:15 +02:00
parent fa6f3ba197
commit f303e7c233

View file

@ -93,12 +93,13 @@ func (s *Server) Handler(path string) http.Handler {
mws := []echo.MiddlewareFunc{
prometheus.StatusMiddleware(prometheus.ComposerSubsystem),
prometheus.HTTPDurationMiddleware(prometheus.ComposerSubsystem),
}
if s.config.JWTEnabled {
mws = append(mws, auth.TenantChannelMiddleware(s.config.TenantProviderFields, HTTPError(ErrorTenantNotFound)))
}
mws = append(mws, prometheus.MetricsMiddleware, s.ValidateRequest)
mws = append(mws,
prometheus.HTTPDurationMiddleware(prometheus.ComposerSubsystem),
prometheus.MetricsMiddleware, s.ValidateRequest)
RegisterHandlers(e.Group(path, mws...), &handler)
return e