From bdc40e91b4f38726b91d1b0a55d9255909ca0d5d Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:21:07 -0600 Subject: [PATCH] only write METHOD PATH | BODY if $DEBUG=true --- config.go | 1 + main.go | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config.go b/config.go index 05effdc..27ee69d 100644 --- a/config.go +++ b/config.go @@ -12,6 +12,7 @@ import ( type Config struct { Port int + Debug bool InitializeSlack bool SlackToken string SlackChannels string diff --git a/main.go b/main.go index 5198348..4dc0a1a 100644 --- a/main.go +++ b/main.go @@ -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) }