mirror of https://github.com/caddyserver/caddy.git
Minor cleanups
This commit is contained in:
parent
0fc97211ab
commit
0ca109db4a
|
@ -52,10 +52,7 @@ func Listen(network, addr string) (net.Listener, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure to start its usage counter at 1
|
// make sure to start its usage counter at 1
|
||||||
lnGlobal := &globalListener{
|
lnGlobal := &globalListener{usage: 1, ln: ln}
|
||||||
usage: 1,
|
|
||||||
ln: ln,
|
|
||||||
}
|
|
||||||
listeners[lnKey] = lnGlobal
|
listeners[lnKey] = lnGlobal
|
||||||
|
|
||||||
return &fakeCloseListener{
|
return &fakeCloseListener{
|
||||||
|
@ -271,8 +268,8 @@ type ParsedAddress struct {
|
||||||
|
|
||||||
// JoinHostPort is like net.JoinHostPort, but where the port
|
// JoinHostPort is like net.JoinHostPort, but where the port
|
||||||
// is StartPort + offset.
|
// is StartPort + offset.
|
||||||
func (l ParsedAddress) JoinHostPort(offset uint) string {
|
func (pa ParsedAddress) JoinHostPort(offset uint) string {
|
||||||
return net.JoinHostPort(l.Host, strconv.Itoa(int(l.StartPort+offset)))
|
return net.JoinHostPort(pa.Host, strconv.Itoa(int(pa.StartPort+offset)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// PortRangeSize returns how many ports are in
|
// PortRangeSize returns how many ports are in
|
||||||
|
|
|
@ -83,6 +83,21 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
|
||||||
return &fsrv, nil
|
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) {
|
func parseTryFiles(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
|
||||||
if !h.Next() {
|
if !h.Next() {
|
||||||
return nil, h.ArgErr()
|
return nil, h.ArgErr()
|
||||||
|
|
15
usagepool.go
15
usagepool.go
|
@ -26,13 +26,14 @@ import (
|
||||||
// are two ways to add values to the pool:
|
// are two ways to add values to the pool:
|
||||||
//
|
//
|
||||||
// 1) LoadOrStore will increment usage and store the
|
// 1) LoadOrStore will increment usage and store the
|
||||||
// value immediately if it does not already exist
|
// value immediately if it does not already exist.
|
||||||
// 2) LoadOrNew will increment usage and construct the
|
// 2) LoadOrNew will atomically check for existence
|
||||||
// value immediately if it does not already exist,
|
// and construct the value immediately if it does
|
||||||
// then store that value in the pool. When the
|
// not already exist, or increment the usage
|
||||||
// constructed value is finally deleted from the
|
// otherwise, then store that value in the pool.
|
||||||
// pool (after its usage reaches 0), it will be
|
// When the constructed value is finally deleted
|
||||||
// cleaned up by calling its Destruct method.
|
// 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
|
// The use of LoadOrNew allows values to be created
|
||||||
// and reused and finally cleaned up only once, even
|
// and reused and finally cleaned up only once, even
|
||||||
|
|
Loading…
Reference in New Issue