only write METHOD PATH | BODY if $DEBUG=true

This commit is contained in:
Bel LaPointe
2024-04-11 17:21:07 -06:00
parent 64af8f5085
commit bdc40e91b4
2 changed files with 6 additions and 3 deletions

View File

@@ -62,9 +62,11 @@ func newHandler(cfg Config) http.HandlerFunc {
mux.Handle("POST /api/v1/events/slack", http.HandlerFunc(newHandlerPostAPIV1EventsSlack(cfg)))
return func(w http.ResponseWriter, r *http.Request) {
b, _ := io.ReadAll(r.Body)
r.Body = io.NopCloser(bytes.NewReader(b))
log.Printf("%s %s | %s", r.Method, r.URL, b)
if cfg.Debug {
b, _ := io.ReadAll(r.Body)
r.Body = io.NopCloser(bytes.NewReader(b))
log.Printf("%s %s | %s", r.Method, r.URL, b)
}
mux.ServeHTTP(w, r)
}