Browse Source

caddyhttp: Support single-line not matcher (#3228)

* caddyhttp: Support single-line not matcher shortcut

* caddyhttp: Some tests, I guess
master
Francis Lavoie 5 years ago
committed by GitHub
parent
commit
a3cfe437b1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      caddyconfig/httpcaddyfile/httptype_test.go
  2. 2
      modules/caddyhttp/matchers.go

22
caddyconfig/httpcaddyfile/httptype_test.go

@ -6,7 +6,7 @@ import (
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
)
func TestServerType(t *testing.T) {
func TestMatcherSyntax(t *testing.T) {
for i, tc := range []struct {
input string
expectWarn bool
@ -30,6 +30,26 @@ func TestServerType(t *testing.T) {
expectWarn: false,
expectError: true,
},
{
input: `http://localhost
@debug {
not {
path /somepath*
}
}
`,
expectWarn: false,
expectError: false,
},
{
input: `http://localhost
@debug {
not path /somepath*
}
`,
expectWarn: false,
expectError: false,
},
} {
adapter := caddyfile.Adapter{

2
modules/caddyhttp/matchers.go

@ -559,7 +559,7 @@ func (m *MatchNot) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
for d.Next() {
var mp matcherPair
matcherMap := make(map[string]RequestMatcher)
for d.NextBlock(0) {
for d.NextArg() || d.NextBlock(0) {
matcherName := d.Val()
mod, err := caddy.GetModule("http.matchers." + matcherName)
if err != nil {

Loading…
Cancel
Save