From 84f9f7cd606146f1a1d6717d369fc98509365de6 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 5 Jul 2019 13:59:30 -0600 Subject: Little cleanups --- README.md | 2 ++ go.mod | 2 +- go.sum | 2 ++ modules/caddyhttp/routes.go | 12 ++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd941bb..d57d306 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/go.mod b/go.mod index 70e7bb6..8f01554 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index a77b794..386283c 100644 --- a/go.sum +++ b/go.sum @@ -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) { -- cgit v1.2.3