Skip to content

Commit

Permalink
✨feature: Forward all known GitHub headers stakater#105
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisam committed Jan 5, 2023
1 parent 39cc2e9 commit 443af80
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ func Parse(req *http.Request, provider providers.Provider) (*providers.Hook, err
}

for _, header := range provider.GetHeaderKeys() {
if req.Header.Get(header) != "" {
hook.Headers[header] = req.Header.Get(header)
continue
if req.Header.Get(header) == "" {
return nil, errors.New("Required header '" + header + "' not found in Request")
}
return nil, errors.New("Required header '" + header + "' not found in Request")

// Store required headers in the expected casing
hook.Headers[header] = req.Header.Get(header)
}

for header := range req.Header {
// Store the rest of the headers in any casing
hook.Headers[header] = req.Header.Get(header)
}

if body, err := ioutil.ReadAll(req.Body); err != nil {
Expand Down

0 comments on commit 443af80

Please sign in to comment.