Browse Source

caddyhttp: Reorder some access log fields; add host matcher test case

This field order reads a little more naturally.
master
Matthew Holt 5 years ago
parent
commit
0bf2565c37
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 6
      modules/caddyhttp/marshalers.go
  2. 5
      modules/caddyhttp/matchers_test.go

6
modules/caddyhttp/marshalers.go

@ -26,11 +26,11 @@ type LoggableHTTPRequest struct{ *http.Request }
// MarshalLogObject satisfies the zapcore.ObjectMarshaler interface.
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("proto", r.Proto)
enc.AddString("method", r.Method)
enc.AddString("host", r.Host)
enc.AddString("uri", r.RequestURI)
enc.AddObject("headers", LoggableHTTPHeader(r.Header))
if r.TLS != nil {
enc.AddObject("tls", LoggableTLSConnState(*r.TLS))

5
modules/caddyhttp/matchers_test.go

@ -122,6 +122,11 @@ func TestHostMatcher(t *testing.T) {
input: "sub.foo.example.net",
expect: false,
},
{
match: MatchHost{"www.*.*"},
input: "www.example.com",
expect: true,
},
{
match: MatchHost{"example.com"},
input: "example.com:5555",

Loading…
Cancel
Save