diff --git a/internal/flags/flags.go b/internal/flags/flags.go index 6454af9d..50430aa8 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -2,6 +2,7 @@ package flags import ( "flag" + "fmt" "strings" "github.com/soulteary/webhook/internal/hook" @@ -30,7 +31,10 @@ func ParseEnvs() AppFlags { hooks := strings.Split(GetEnvStr(ENV_KEY_HOOKS, ""), ",") var hooksFiles hook.HooksFiles for _, hook := range hooks { - hooksFiles.Set(hook) + err := hooksFiles.Set(hook) + if err != nil { + fmt.Println("Error parsing hooks from environment variable: ", err) + } } if len(hooksFiles) > 0 { flags.HooksFiles = hooksFiles diff --git a/internal/middleware/dumper.go b/internal/middleware/dumper.go index ae0e1107..527d332b 100644 --- a/internal/middleware/dumper.go +++ b/internal/middleware/dumper.go @@ -46,7 +46,10 @@ func Dumper(w io.Writer) func(http.Handler) http.Handler { buf.WriteString(sc.Text() + "\n") } - w.Write(buf.Bytes()) + _, err = w.Write(buf.Bytes()) + if err != nil { + fmt.Println("Error writing to debug writer before buf reset: ", err) + } buf.Reset() // Dump Response @@ -79,7 +82,10 @@ func Dumper(w io.Writer) func(http.Handler) http.Handler { buf.WriteString(sc.Text() + "\n") } } - w.Write(buf.Bytes()) + _, err = w.Write(buf.Bytes()) + if err != nil { + fmt.Println("Error writing to debug writer: ", err) + } }) } }