0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2025-01-06 22:40:31 -05:00

Little cleanups

This commit is contained in:
Matthew Holt 2019-07-05 13:59:30 -06:00
parent 79216d356c
commit 84f9f7cd60
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
4 changed files with 17 additions and 1 deletions

View file

@ -238,6 +238,8 @@ Ultimately, we think all these properties are appropriate -- if not ideal -- for
If you're still not happy with the choice of JSON, feel free to contribute a config adapter of your own choice! If you're still not happy with the choice of JSON, feel free to contribute a config adapter of your own choice!
Or just use YAML or TOML, which seamlessly translate to JSON.
### JSON is declarative; what if I need more programmability (i.e. imperative syntax)? ### JSON is declarative; what if I need more programmability (i.e. imperative syntax)?
We have good news. We have good news.

2
go.mod
View file

@ -7,7 +7,7 @@ require (
github.com/Masterminds/goutils v1.1.0 // indirect github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.4.2 // indirect github.com/Masterminds/semver v1.4.2 // indirect
github.com/Masterminds/sprig v2.20.0+incompatible github.com/Masterminds/sprig v2.20.0+incompatible
github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb github.com/andybalholm/brotli v0.0.0-20190704151324-71eb68cc467c
github.com/dustin/go-humanize v1.0.0 github.com/dustin/go-humanize v1.0.0
github.com/go-acme/lego v2.6.0+incompatible github.com/go-acme/lego v2.6.0+incompatible
github.com/google/go-cmp v0.3.0 // indirect github.com/google/go-cmp v0.3.0 // indirect

2
go.sum
View file

@ -8,6 +8,8 @@ github.com/Masterminds/sprig v2.20.0+incompatible h1:dJTKKuUkYW3RMFdQFXPU/s6hg10
github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb h1:Qs8/an94NFS1x2nn7rSI+skKFuw/EGfEYAGS3w/p+jc= github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb h1:Qs8/an94NFS1x2nn7rSI+skKFuw/EGfEYAGS3w/p+jc=
github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U= github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U=
github.com/andybalholm/brotli v0.0.0-20190704151324-71eb68cc467c h1:pBKtfXLqKZ+GPHGjlBheGaXK2lddydUG3XhWGrYjxOA=
github.com/andybalholm/brotli v0.0.0-20190704151324-71eb68cc467c/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U=
github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY= github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY=
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=

View file

@ -39,6 +39,18 @@ type ServerRoute struct {
responder Handler responder Handler
} }
// Empty returns true if the route has all zero/default values.
func (sr ServerRoute) Empty() bool {
return len(sr.MatcherSets) == 0 &&
len(sr.Apply) == 0 &&
len(sr.Respond) == 0 &&
len(sr.matcherSets) == 0 &&
len(sr.middleware) == 0 &&
sr.responder == nil &&
!sr.Terminal &&
sr.Group == ""
}
func (sr ServerRoute) anyMatcherSetMatches(r *http.Request) bool { func (sr ServerRoute) anyMatcherSetMatches(r *http.Request) bool {
for _, ms := range sr.matcherSets { for _, ms := range sr.matcherSets {
if ms.Match(r) { if ms.Match(r) {