diff --git a/main.go b/main.go index 9bc0511..4d46241 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,17 @@ type alert struct { func (rcv *receiver) handleWebhooks(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() + if r.Method != http.MethodPost { + rcv.logger.Errorf("illegal HTTP method: expected %q, got %q", "POST", r.Method) + return + } + + contentType := r.Header.Get("Content-Type") + if contentType != "application/json" { + rcv.logger.Errorf("illegal content type: %s", contentType) + return + } + var event payload if err := json.NewDecoder(r.Body).Decode(&event); err != nil { rcv.logger.Error(err)