Add debugging

This commit is contained in:
Dean Karn
2017-04-25 11:11:43 -04:00
parent fccbba5986
commit 19138534b5
2 changed files with 182 additions and 60 deletions
+12 -2
View File
@@ -1,6 +1,9 @@
package webhooks
import "net/http"
import (
"log"
"net/http"
)
// Header provides http.Header to minimize imports
type Header http.Header
@@ -85,16 +88,23 @@ func RunTLSServer(s *http.Server, hook Webhook, path string) error {
// ServeHTTP is the Handler for every posted WebHook Event
func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
defer func() {
log.Println("Closing Request Body")
r.Body.Close()
}()
log.Println("HTTP METHOD:", r.Method)
if r.Method != "POST" {
http.Error(w, "405 Method not allowed", http.StatusMethodNotAllowed)
return
}
log.Println("Chking that paths match:", r.URL.Path == s.path)
if r.URL.Path != s.path {
http.Error(w, "404 Not found", http.StatusNotFound)
return
}
log.Println("Parsing Payload")
s.hook.ParsePayload(w, r)
}