mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-14 23:06:27 +03:00
caddyhttp: Reorder some access log fields; add host matcher test case
This field order reads a little more naturally.
This commit is contained in:
parent
7bfe5b6c95
commit
0bf2565c37
2 changed files with 8 additions and 3 deletions
|
@ -26,11 +26,11 @@ type LoggableHTTPRequest struct{ *http.Request }
|
||||||
|
|
||||||
// MarshalLogObject satisfies the zapcore.ObjectMarshaler interface.
|
// MarshalLogObject satisfies the zapcore.ObjectMarshaler interface.
|
||||||
func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
||||||
enc.AddString("method", r.Method)
|
|
||||||
enc.AddString("uri", r.RequestURI)
|
|
||||||
enc.AddString("proto", r.Proto)
|
|
||||||
enc.AddString("remote_addr", r.RemoteAddr)
|
enc.AddString("remote_addr", r.RemoteAddr)
|
||||||
|
enc.AddString("proto", r.Proto)
|
||||||
|
enc.AddString("method", r.Method)
|
||||||
enc.AddString("host", r.Host)
|
enc.AddString("host", r.Host)
|
||||||
|
enc.AddString("uri", r.RequestURI)
|
||||||
enc.AddObject("headers", LoggableHTTPHeader(r.Header))
|
enc.AddObject("headers", LoggableHTTPHeader(r.Header))
|
||||||
if r.TLS != nil {
|
if r.TLS != nil {
|
||||||
enc.AddObject("tls", LoggableTLSConnState(*r.TLS))
|
enc.AddObject("tls", LoggableTLSConnState(*r.TLS))
|
||||||
|
|
|
@ -122,6 +122,11 @@ func TestHostMatcher(t *testing.T) {
|
||||||
input: "sub.foo.example.net",
|
input: "sub.foo.example.net",
|
||||||
expect: false,
|
expect: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
match: MatchHost{"www.*.*"},
|
||||||
|
input: "www.example.com",
|
||||||
|
expect: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
match: MatchHost{"example.com"},
|
match: MatchHost{"example.com"},
|
||||||
input: "example.com:5555",
|
input: "example.com:5555",
|
||||||
|
|
Loading…
Reference in a new issue