mirror of
https://github.com/alvierahman90/gohookr.git
synced 2024-11-22 08:49:53 +00:00
Clean up code
This commit is contained in:
parent
242ae06cad
commit
c0f0cc6c60
11
main.go
11
main.go
@ -40,10 +40,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func webhook(w http.ResponseWriter, r *http.Request) {
|
func webhook(w http.ResponseWriter, r *http.Request) {
|
||||||
// TODO run any specified tests before running script
|
|
||||||
|
|
||||||
service_name := mux.Vars(r)["service"]
|
|
||||||
|
|
||||||
payload := ""
|
payload := ""
|
||||||
if p, err := ioutil.ReadAll(r.Body); err != nil {
|
if p, err := ioutil.ReadAll(r.Body); err != nil {
|
||||||
writeResponse(w, 500, "Internal Server Error: Could not read payload")
|
writeResponse(w, 500, "Internal Server Error: Could not read payload")
|
||||||
@ -60,12 +56,11 @@ func webhook(w http.ResponseWriter, r *http.Request) {
|
|||||||
config := Config{}
|
config := Config{}
|
||||||
json.Unmarshal(raw_config, &config)
|
json.Unmarshal(raw_config, &config)
|
||||||
|
|
||||||
var service = Service{}
|
// check what service is specified in URL (/webhook/{service}) and if it exists
|
||||||
if val, ok := config.Services[string(service_name)]; !ok {
|
service, ok := config.Services[string(mux.Vars(r)["service"])]
|
||||||
|
if !ok {
|
||||||
writeResponse(w, 404, "Service Not Found")
|
writeResponse(w, 404, "Service Not Found")
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
service = val
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that signature provided matches signature calculated using secretsss
|
// Verify that signature provided matches signature calculated using secretsss
|
||||||
|
Loading…
Reference in New Issue
Block a user