github_hook.go
func (g GithubHook) handleSignature(r *http.Request, body []byte, secret string) error {
	signature := r.Header.Get("X-Hub-Signature")
	if signature != "" {
		if secret == "" {
			Logger().Print("Unable to verify request signature. Secret not set in caddyfile!\n")
		} else {
			mac := hmac.New(sha1.New, []byte(secret))
			mac.Write(body)
			expectedMac := hex.EncodeToString(mac.Sum(nil))

			if signature[5:] != expectedMac {
				return errors.New("could not verify request signature. The signature is invalid")
			}
		}
	}

	return nil
}
func (g GithubHook) handleSignature(r *http.Request, body []byte, secret string) error {
	signature := r.Header.Get("X-Hub-Signature")
	if signature != "" {
		if secret == "" {
			Logger().Print("Unable to verify request signature. Secret not set in caddyfile!\n")
		} else {
			mac := hmac.New(sha1.New, []byte(secret))
			mac.Write(body)
			expectedMac := hex.EncodeToString(mac.Sum(nil))

			if signature[5:] != expectedMac {
				return errors.New("could not verify request signature. The signature is invalid")
			}
		}
	}

	return nil
}
// Check for an optional signature in the request
// if it is signed, verify the signature.