From 284fb3a98cae2e6e6ca79327988230a3a916996a Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 22 May 2019 13:13:39 -0600 Subject: Allow multiple matcher sets in routes (OR'ed together) Also export MatchRegexp in case other matcher modules find it useful. Add comments to the exported matchers. --- modules/caddyhttp/matchers_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'modules/caddyhttp/matchers_test.go') diff --git a/modules/caddyhttp/matchers_test.go b/modules/caddyhttp/matchers_test.go index 30b45f6..5e62a90 100644 --- a/modules/caddyhttp/matchers_test.go +++ b/modules/caddyhttp/matchers_test.go @@ -176,38 +176,38 @@ func TestPathREMatcher(t *testing.T) { expect: true, }, { - match: MatchPathRE{matchRegexp{Pattern: "/"}}, + match: MatchPathRE{MatchRegexp{Pattern: "/"}}, input: "/", expect: true, }, { - match: MatchPathRE{matchRegexp{Pattern: "/foo"}}, + match: MatchPathRE{MatchRegexp{Pattern: "/foo"}}, input: "/foo", expect: true, }, { - match: MatchPathRE{matchRegexp{Pattern: "/foo"}}, + match: MatchPathRE{MatchRegexp{Pattern: "/foo"}}, input: "/foo/", expect: true, }, { - match: MatchPathRE{matchRegexp{Pattern: "/bar"}}, + match: MatchPathRE{MatchRegexp{Pattern: "/bar"}}, input: "/foo/", expect: false, }, { - match: MatchPathRE{matchRegexp{Pattern: "^/bar"}}, + match: MatchPathRE{MatchRegexp{Pattern: "^/bar"}}, input: "/foo/bar", expect: false, }, { - match: MatchPathRE{matchRegexp{Pattern: "^/foo/(.*)/baz$", Name: "name"}}, + match: MatchPathRE{MatchRegexp{Pattern: "^/foo/(.*)/baz$", Name: "name"}}, input: "/foo/bar/baz", expect: true, expectRepl: map[string]string{"name.1": "bar"}, }, { - match: MatchPathRE{matchRegexp{Pattern: "^/foo/(?P.*)/baz$", Name: "name"}}, + match: MatchPathRE{MatchRegexp{Pattern: "^/foo/(?P.*)/baz$", Name: "name"}}, input: "/foo/bar/baz", expect: true, expectRepl: map[string]string{"name.myparam": "bar"}, @@ -315,17 +315,17 @@ func TestHeaderREMatcher(t *testing.T) { expectRepl map[string]string }{ { - match: MatchHeaderRE{"Field": &matchRegexp{Pattern: "foo"}}, + match: MatchHeaderRE{"Field": &MatchRegexp{Pattern: "foo"}}, input: http.Header{"Field": []string{"foo"}}, expect: true, }, { - match: MatchHeaderRE{"Field": &matchRegexp{Pattern: "$foo^"}}, + match: MatchHeaderRE{"Field": &MatchRegexp{Pattern: "$foo^"}}, input: http.Header{"Field": []string{"foobar"}}, expect: false, }, { - match: MatchHeaderRE{"Field": &matchRegexp{Pattern: "^foo(.*)$", Name: "name"}}, + match: MatchHeaderRE{"Field": &MatchRegexp{Pattern: "^foo(.*)$", Name: "name"}}, input: http.Header{"Field": []string{"foobar"}}, expect: true, expectRepl: map[string]string{"name.1": "bar"}, -- cgit v1.2.3