From c0f0cc6c606a10e35b566ba3305fe27a9595250a Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Thu, 29 Jul 2021 07:30:19 +0100 Subject: [PATCH] Clean up code --- main.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 7868f02..10c13f1 100644 --- a/main.go +++ b/main.go @@ -40,10 +40,6 @@ func main() { } func webhook(w http.ResponseWriter, r *http.Request) { - // TODO run any specified tests before running script - - service_name := mux.Vars(r)["service"] - payload := "" if p, err := ioutil.ReadAll(r.Body); err != nil { writeResponse(w, 500, "Internal Server Error: Could not read payload") @@ -60,12 +56,11 @@ func webhook(w http.ResponseWriter, r *http.Request) { config := Config{} json.Unmarshal(raw_config, &config) - var service = Service{} - if val, ok := config.Services[string(service_name)]; !ok { + // check what service is specified in URL (/webhook/{service}) and if it exists + service, ok := config.Services[string(mux.Vars(r)["service"])] + if !ok { writeResponse(w, 404, "Service Not Found") return - } else { - service = val } // Verify that signature provided matches signature calculated using secretsss