mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-25 09:40:13 +08:00
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
|
||||
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
|
||||
|
|
|
@ -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()
|
||||
|
|
17
usagepool.go
17
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user