Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
Minor improvements; comments and shorter placeholders & module IDs
Matthew Holt committed
Dec 12, 2019 at 14:31 UTC
87b6cf470baacd659cd20815de2804ae4a31df7f
7 files changed
+19
-15
logging.go
+2
-2
@@ -561,10 +561,10 @@ type LogSampling struct {
561
}
562
563
type (
564
- // StdoutWriter can write logs to stdout.
564
+ // StdoutWriter writes logs to standard out.
565
StdoutWriter struct{}
566
567
- // StderrWriter can write logs to stdout.
567
+ // StderrWriter writes logs to standard error.
568
StderrWriter struct{}
569
570
// DiscardWriter discards all writes.
modules/caddyhttp/caddyauth/caddyauth.go
+1
-1
@@ -74,7 +74,7 @@ func (a Authentication) ServeHTTP(w http.ResponseWriter, r *http.Request, next c
74
}
75
76
repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
77
- repl.Set("http.handlers.authentication.user.id", user.ID)
77
+ repl.Set("http.authentication.user.id", user.ID)
78
79
return next.ServeHTTP(w, r)
80
}
modules/caddyhttp/matchers.go
+1
-1
@@ -596,7 +596,7 @@ func (m MatchRemoteIP) Match(r *http.Request) bool {
596
// CaddyModule returns the Caddy module information.
597
func (MatchStarlarkExpr) CaddyModule() caddy.ModuleInfo {
598
return caddy.ModuleInfo{
599
- ID: "http.matchers.starlark_expr", // TODO: Rename to 'starlark'?
599
+ ID: "http.matchers.starlark",
600
New: func() caddy.Module { return new(MatchStarlarkExpr) },
601
}
602
}
modules/caddyhttp/reverseproxy/caddyfile.go
+2
-2
@@ -106,7 +106,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
106
return d.Err("load balancing selection policy already specified")
107
}
108
name := d.Val()
109
- mod, err := caddy.GetModule("http.handlers.reverse_proxy.selection_policies." + name)
109
+ mod, err := caddy.GetModule("http.reverse_proxy.selection_policies." + name)
110
if err != nil {
111
return d.Errf("getting load balancing policy module '%s': %v", mod, err)
112
}
@@ -389,7 +389,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
389
return d.Err("transport already specified")
390
}
391
name := d.Val()
392
- mod, err := caddy.GetModule("http.handlers.reverse_proxy.transport." + name)
392
+ mod, err := caddy.GetModule("http.reverse_proxy.transport." + name)
393
if err != nil {
394
return d.Errf("getting transport module '%s': %v", mod, err)
395
}
modules/caddyhttp/reverseproxy/command.go
+1
-1
@@ -100,7 +100,7 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) {
100
Headers: &headers.Handler{
101
Request: &headers.HeaderOps{
102
Set: http.Header{
103
- "Host": []string{"{http.handlers.reverse_proxy.upstream.host}"},
103
+ "Host": []string{"{http.reverse_proxy.upstream.host}"},
104
},
105
},
106
},
modules/caddyhttp/reverseproxy/reverseproxy.go
+7
-7
@@ -288,13 +288,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
288
r = r.WithContext(ctx)
289
290
// set placeholders with information about this upstream
291
- repl.Set("http.handlers.reverse_proxy.upstream.address", dialInfo.String())
292
- repl.Set("http.handlers.reverse_proxy.upstream.hostport", dialInfo.Address)
293
- repl.Set("http.handlers.reverse_proxy.upstream.host", dialInfo.Host)
294
- repl.Set("http.handlers.reverse_proxy.upstream.port", dialInfo.Port)
295
- repl.Set("http.handlers.reverse_proxy.upstream.requests", strconv.Itoa(upstream.Host.NumRequests()))
296
- repl.Set("http.handlers.reverse_proxy.upstream.max_requests", strconv.Itoa(upstream.MaxRequests))
297
- repl.Set("http.handlers.reverse_proxy.upstream.fails", strconv.Itoa(upstream.Host.Fails()))
291
+ repl.Set("http.reverse_proxy.upstream.address", dialInfo.String())
292
+ repl.Set("http.reverse_proxy.upstream.hostport", dialInfo.Address)
293
+ repl.Set("http.reverse_proxy.upstream.host", dialInfo.Host)
294
+ repl.Set("http.reverse_proxy.upstream.port", dialInfo.Port)
295
+ repl.Set("http.reverse_proxy.upstream.requests", strconv.Itoa(upstream.Host.NumRequests()))
296
+ repl.Set("http.reverse_proxy.upstream.max_requests", strconv.Itoa(upstream.MaxRequests))
297
+ repl.Set("http.reverse_proxy.upstream.fails", strconv.Itoa(upstream.Host.Fails()))
298
299
// mutate request headers according to this upstream;
300
// because we're in a retry loop, we have to copy
modules/caddyhttp/server.go
+5
-1
@@ -447,6 +447,10 @@ func (*HTTPErrorConfig) WithError(r *http.Request, err error) *http.Request {
447
448
// ServerLogConfig describes a server's logging configuration.
449
type ServerLogConfig struct {
450
+ // LoggerNames maps request hostnames to a custom logger name.
451
+ // For example, a mapping of "example.com" to "example" would
452
+ // cause access logs from requests with a Host of example.com
453
+ // to be emitted by a logger named "http.log.access.example".
454
LoggerNames map[string]string `json:"logger_names,omitempty"`
455
}
456
@@ -504,7 +508,7 @@ func cloneURL(from, to *url.URL) {
508
509
const (
510
// CommonLogFormat is the common log format. https://en.wikipedia.org/wiki/Common_Log_Format
507
- CommonLogFormat = `{http.request.remote.host} ` + CommonLogEmptyValue + ` {http.handlers.authentication.user.id} [{time.now.common_log}] "{http.request.orig_method} {http.request.orig_uri} {http.request.proto}" {http.response.status} {http.response.size}`
511
+ CommonLogFormat = `{http.request.remote.host} ` + CommonLogEmptyValue + ` {http.authentication.user.id} [{time.now.common_log}] "{http.request.orig_method} {http.request.orig_uri} {http.request.proto}" {http.response.status} {http.response.size}`
512
513
// CommonLogEmptyValue is the common empty log value.
514
CommonLogEmptyValue = "-"