Skip to content

Commit

Permalink
fix(timeout): Fix the swagger issue introduce after fixing #2758
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant committed Dec 13, 2024
1 parent e81df19 commit 5716293
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/relayproxy/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (s *Server) initRoutes() {
s.apiEcho.HideBanner = true
s.apiEcho.HidePort = true
s.apiEcho.Debug = s.config.IsDebugEnabled()
s.apiEcho.Use(otelecho.Middleware("go-feature-flag"))
// Timeout middleware has to be the first middleware in the list
// (see: https://github.com/labstack/echo/blob/3b017855b4d331002e2b8b28e903679b875ae3e9/middleware/timeout.go#L17)
s.apiEcho.Use(middleware.TimeoutWithConfig(
Expand All @@ -70,10 +69,12 @@ func (s *Server) initRoutes() {
ErrorMessage: `Timeout on the server, please retry later`,
}),
)
s.apiEcho.Use(otelecho.Middleware("go-feature-flag"))
s.apiEcho.Use(custommiddleware.ZapLogger(s.zapLog, s.config))
s.apiEcho.Use(middleware.BodyDumpWithConfig(middleware.BodyDumpConfig{
Skipper: func(_ echo.Context) bool {
return !s.zapLog.Core().Enabled(zap.DebugLevel)
Skipper: func(c echo.Context) bool {
isSwagger := strings.HasPrefix(c.Request().URL.String(), "/swagger")
return isSwagger || !s.zapLog.Core().Enabled(zap.DebugLevel)
},
Handler: func(_ echo.Context, reqBody []byte, _ []byte) {
s.zapLog.Debug("Request info", zap.ByteString("request_body", reqBody))
Expand Down

0 comments on commit 5716293

Please sign in to comment.