Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
caddyhttp: Support single-line not matcher (#3228)
* caddyhttp: Support single-line not matcher shortcut * caddyhttp: Some tests, I guess
Francis Lavoie committed
Apr 6, 2020 at 15:05 UTC
a3cfe437b1d27fa0eb20d112de7c257cb25e4ea7
2 files changed
+24
-4
caddyconfig/httpcaddyfile/httptype_test.go
+23
-3
@@ -6,7 +6,7 @@ import (
6
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
7
)
8
9
-func TestServerType(t *testing.T) {
9
+func TestMatcherSyntax(t *testing.T) {
10
for i, tc := range []struct {
11
input string
12
expectWarn bool
@@ -15,7 +15,7 @@ func TestServerType(t *testing.T) {
15
{
16
input: `http://localhost
17
@debug {
18
- query showdebug=1
18
+ query showdebug=1
19
}
20
`,
21
expectWarn: false,
@@ -24,12 +24,32 @@ func TestServerType(t *testing.T) {
24
{
25
input: `http://localhost
26
@debug {
27
- query bad format
27
+ query bad format
28
}
29
`,
30
expectWarn: false,
31
expectError: true,
32
},
33
+ {
34
+ input: `http://localhost
35
+ @debug {
36
+ not {
37
+ path /somepath*
38
+ }
39
+ }
40
+ `,
41
+ expectWarn: false,
42
+ expectError: false,
43
+ },
44
+ {
45
+ input: `http://localhost
46
+ @debug {
47
+ not path /somepath*
48
+ }
49
+ `,
50
+ expectWarn: false,
51
+ expectError: false,
52
+ },
53
} {
54
55
adapter := caddyfile.Adapter{
modules/caddyhttp/matchers.go
+1
-1
@@ -559,7 +559,7 @@ func (m *MatchNot) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
559
for d.Next() {
560
var mp matcherPair
561
matcherMap := make(map[string]RequestMatcher)
562
- for d.NextBlock(0) {
562
+ for d.NextArg() || d.NextBlock(0) {
563
matcherName := d.Val()
564
mod, err := caddy.GetModule("http.matchers." + matcherName)
565
if err != nil {