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: Rename MatchNegate type to MatchNot type
This is more congruent with its module name. A change that affects only code, not configurations.
Matthew Holt committed
Mar 30, 2020 at 11:53 UTC
ac65f690ae9dee3ab6d3c634cffd0b41252cb343
2 files changed
+15
-15
modules/caddyhttp/matchers.go
+14
-14
@@ -99,10 +99,10 @@ type (
99
cidrs []*net.IPNet
100
}
101
102
- // MatchNegate matches requests by negating its matchers' results.
102
+ // MatchNot matches requests by negating its matchers' results.
103
// To use, simply specify a set of matchers like you normally would;
104
// the only difference is that their result will be negated.
105
- MatchNegate struct {
105
+ MatchNot struct {
106
MatchersRaw caddy.ModuleMap `json:"-" caddy:"namespace=http.matchers"`
107
108
Matchers MatcherSet `json:"-"`
@@ -119,7 +119,7 @@ func init() {
119
caddy.RegisterModule(MatchHeaderRE{})
120
caddy.RegisterModule(new(MatchProtocol))
121
caddy.RegisterModule(MatchRemoteIP{})
122
- caddy.RegisterModule(MatchNegate{})
122
+ caddy.RegisterModule(MatchNot{})
123
}
124
125
// CaddyModule returns the Caddy module information.
@@ -531,10 +531,10 @@ func (m *MatchProtocol) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
531
}
532
533
// CaddyModule returns the Caddy module information.
534
-func (MatchNegate) CaddyModule() caddy.ModuleInfo {
534
+func (MatchNot) CaddyModule() caddy.ModuleInfo {
535
return caddy.ModuleInfo{
536
ID: "http.matchers.not",
537
- New: func() caddy.Module { return new(MatchNegate) },
537
+ New: func() caddy.Module { return new(MatchNot) },
538
}
539
}
540
@@ -542,17 +542,17 @@ func (MatchNegate) CaddyModule() caddy.ModuleInfo {
542
// This is done because we cannot embed the map directly into
543
// the struct, but we need a struct because we need another
544
// field just for the provisioned modules.
545
-func (m *MatchNegate) UnmarshalJSON(data []byte) error {
545
+func (m *MatchNot) UnmarshalJSON(data []byte) error {
546
return json.Unmarshal(data, &m.MatchersRaw)
547
}
548
549
// MarshalJSON marshals m's matchers.
550
-func (m MatchNegate) MarshalJSON() ([]byte, error) {
550
+func (m MatchNot) MarshalJSON() ([]byte, error) {
551
return json.Marshal(m.MatchersRaw)
552
}
553
554
// UnmarshalCaddyfile implements caddyfile.Unmarshaler.
555
-func (m *MatchNegate) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
555
+func (m *MatchNot) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
556
// first, unmarshal each matcher in the set from its tokens
557
558
matcherMap := make(map[string]RequestMatcher)
@@ -593,7 +593,7 @@ func (m *MatchNegate) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
593
}
594
595
// Provision loads the matcher modules to be negated.
596
-func (m *MatchNegate) Provision(ctx caddy.Context) error {
596
+func (m *MatchNot) Provision(ctx caddy.Context) error {
597
mods, err := ctx.LoadModule(m, "MatchersRaw")
598
if err != nil {
599
return fmt.Errorf("loading matchers: %v", err)
@@ -606,7 +606,7 @@ func (m *MatchNegate) Provision(ctx caddy.Context) error {
606
607
// Match returns true if r matches m. Since this matcher negates the
608
// embedded matchers, false is returned if any of its matchers match.
609
-func (m MatchNegate) Match(r *http.Request) bool {
609
+func (m MatchNot) Match(r *http.Request) bool {
610
return !m.Matchers.Match(r)
611
}
612
@@ -851,8 +851,8 @@ var (
851
_ RequestMatcher = (*MatchProtocol)(nil)
852
_ RequestMatcher = (*MatchRemoteIP)(nil)
853
_ caddy.Provisioner = (*MatchRemoteIP)(nil)
854
- _ RequestMatcher = (*MatchNegate)(nil)
855
- _ caddy.Provisioner = (*MatchNegate)(nil)
854
+ _ RequestMatcher = (*MatchNot)(nil)
855
+ _ caddy.Provisioner = (*MatchNot)(nil)
856
_ caddy.Provisioner = (*MatchRegexp)(nil)
857
858
_ caddyfile.Unmarshaler = (*MatchHost)(nil)
@@ -865,6 +865,6 @@ var (
865
_ caddyfile.Unmarshaler = (*MatchProtocol)(nil)
866
_ caddyfile.Unmarshaler = (*MatchRemoteIP)(nil)
867
868
- _ json.Marshaler = (*MatchNegate)(nil)
869
- _ json.Unmarshaler = (*MatchNegate)(nil)
868
+ _ json.Marshaler = (*MatchNot)(nil)
869
+ _ json.Unmarshaler = (*MatchNot)(nil)
870
)
modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
+1
-1
@@ -127,7 +127,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
127
"file": h.JSON(fileserver.MatchFile{
128
TryFiles: []string{"{http.request.uri.path}/index.php"},
129
}),
130
- "not": h.JSON(caddyhttp.MatchNegate{
130
+ "not": h.JSON(caddyhttp.MatchNot{
131
MatchersRaw: caddy.ModuleMap{
132
"path": h.JSON(caddyhttp.MatchPath{"*/"}),
133
},