Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: request_headers error condition implementation fixed #373

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/pipeline/errorhandlers/matcher/header_matcher.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package matcher

import (
"golang.org/x/exp/slices"
"strings"
)

type HeaderMatcher map[string][]string

func (hm HeaderMatcher) Match(headers map[string]string) bool {
for name, valueList := range hm {
headerVal, found := headers[name]
if found && slices.Contains(valueList, headerVal) {
return true
if found {
for _, val := range valueList {
if strings.Contains(headerVal, val) {
return true
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestHeaderMatcher(t *testing.T) {
headers: map[string][]string{
"foobar": {"foo", "bar"},
},
match: map[string]string{"foobar": "bar"},
match: map[string]string{"foobar": "bar,baz"},
matching: true,
},
{
Expand All @@ -30,8 +30,8 @@ func TestHeaderMatcher(t *testing.T) {
"some-header": {"value1", "value2"},
},
match: map[string]string{
"foobar": "bar",
"some-header": "value1",
"foobar": "bar,foo",
"some-header": "value1,val3",
},
matching: true,
},
Expand Down