only write METHOD PATH | BODY if $DEBUG=true

main
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

@ -12,6 +12,7 @@ import (
type Config struct {
Port int
Debug bool
InitializeSlack bool
SlackToken string
SlackChannels string

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) {
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)
}