Add debugging
This commit is contained in:
+12
-2
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user