only write METHOD PATH | BODY if $DEBUG=true
parent
64af8f5085
commit
bdc40e91b4
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
type Config struct {
|
||||
Port int
|
||||
Debug bool
|
||||
InitializeSlack bool
|
||||
SlackToken string
|
||||
SlackChannels string
|
||||
|
|
|
|||
8
main.go
8
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue