Skip to content

Commit

Permalink
fix: remove /health from logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed May 16, 2024
1 parent de45b3f commit 2b20094
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/observability/request-logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ func AddRequestID(globalConfig *conf.GlobalConfiguration) func(next http.Handler
}

func NewStructuredLogger(logger *logrus.Logger, config *conf.GlobalConfiguration) func(next http.Handler) http.Handler {
return chimiddleware.RequestLogger(&structuredLogger{logger, config})
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/health" {
next.ServeHTTP(w, r)
} else {
chimiddleware.RequestLogger(&structuredLogger{logger, config})(next).ServeHTTP(w, r)
}
})
}
}

type structuredLogger struct {
Expand Down

0 comments on commit 2b20094

Please sign in to comment.