diff options
author | Matthew Holt <[email protected]> | 2019-11-15 12:47:38 -0700 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-11-15 12:47:38 -0700 |
commit | 0ca109db4ab0b8869a15d388ef9036d9117ec081 (patch) | |
tree | a256f55db132575b8a8d44a1ff253b3456643bc9 | |
parent | 0fc97211abd46098f5953fc6b152aa891060fca5 (diff) | |
download | caddy-0ca109db4ab0b8869a15d388ef9036d9117ec081.tar.gz caddy-0ca109db4ab0b8869a15d388ef9036d9117ec081.zip |
Minor cleanups
-rw-r--r-- | listeners.go | 9 | ||||
-rw-r--r-- | modules/caddyhttp/fileserver/caddyfile.go | 15 | ||||
-rw-r--r-- | usagepool.go | 17 |
3 files changed, 27 insertions, 14 deletions
diff --git a/listeners.go b/listeners.go index 37b4c299f..46446420a 100644 --- a/listeners.go +++ b/listeners.go @@ -52,10 +52,7 @@ func Listen(network, addr string) (net.Listener, error) { } // make sure to start its usage counter at 1 - lnGlobal := &globalListener{ - usage: 1, - ln: ln, - } + lnGlobal := &globalListener{usage: 1, ln: ln} listeners[lnKey] = lnGlobal return &fakeCloseListener{ @@ -271,8 +268,8 @@ type ParsedAddress struct { // JoinHostPort is like net.JoinHostPort, but where the port // is StartPort + offset. -func (l ParsedAddress) JoinHostPort(offset uint) string { - return net.JoinHostPort(l.Host, strconv.Itoa(int(l.StartPort+offset))) +func (pa ParsedAddress) JoinHostPort(offset uint) string { + return net.JoinHostPort(pa.Host, strconv.Itoa(int(pa.StartPort+offset))) } // PortRangeSize returns how many ports are in diff --git a/modules/caddyhttp/fileserver/caddyfile.go b/modules/caddyhttp/fileserver/caddyfile.go index b50c1664d..06540bcb5 100644 --- a/modules/caddyhttp/fileserver/caddyfile.go +++ b/modules/caddyhttp/fileserver/caddyfile.go @@ -83,6 +83,21 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) return &fsrv, nil } +// parseTryFiles parses the try_files directive. It combines a file matcher +// with a rewrite directive, so this is not a standard handler directive. +// A try_files directive has this syntax (notice no matcher tokens accepted): +// +// try_files <files...> +// +// and is shorthand for: +// +// matcher:try_files { +// file { +// try_files <files...> +// } +// } +// rewrite match:try_files {http.matchers.file.relative}{http.request.uri.query_string} +// func parseTryFiles(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) { if !h.Next() { return nil, h.ArgErr() diff --git a/usagepool.go b/usagepool.go index df69caffc..6fd48f5b4 100644 --- a/usagepool.go +++ b/usagepool.go @@ -25,14 +25,15 @@ import ( // only inserted if they do not already exist. There // are two ways to add values to the pool: // -// 1) LoadOrStore will increment usage and store the -// value immediately if it does not already exist -// 2) LoadOrNew will increment usage and construct the -// value immediately if it does not already exist, -// then store that value in the pool. When the -// constructed value is finally deleted from the -// pool (after its usage reaches 0), it will be -// cleaned up by calling its Destruct method. +// 1) LoadOrStore will increment usage and store the +// value immediately if it does not already exist. +// 2) LoadOrNew will atomically check for existence +// and construct the value immediately if it does +// not already exist, or increment the usage +// otherwise, then store that value in the pool. +// When the constructed value is finally deleted +// from the pool (when its usage reaches 0), it +// will be cleaned up by calling Destruct(). // // The use of LoadOrNew allows values to be created // and reused and finally cleaned up only once, even |