diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | modules/caddyhttp/routes.go | 12 |
4 files changed, 17 insertions, 1 deletions
@@ -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! +Or just use YAML or TOML, which seamlessly translate to JSON. + ### JSON is declarative; what if I need more programmability (i.e. imperative syntax)? We have good news. @@ -7,7 +7,7 @@ require ( github.com/Masterminds/goutils v1.1.0 // indirect github.com/Masterminds/semver v1.4.2 // indirect 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/go-acme/lego v2.6.0+incompatible github.com/google/go-cmp v0.3.0 // indirect @@ -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/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-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/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= diff --git a/modules/caddyhttp/routes.go b/modules/caddyhttp/routes.go index 0882be6..5e61fae 100644 --- a/modules/caddyhttp/routes.go +++ b/modules/caddyhttp/routes.go @@ -39,6 +39,18 @@ type ServerRoute struct { 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 { for _, ms := range sr.matcherSets { if ms.Match(r) { |