mirror of https://github.com/caddyserver/caddy.git
caddyhttp: Fix panic when request missing ClientIPVarKey (#6040)
This commit is contained in:
parent
750d0b8331
commit
f5344f8cad
|
@ -40,7 +40,9 @@ func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
||||||
|
|
||||||
enc.AddString("remote_ip", ip)
|
enc.AddString("remote_ip", ip)
|
||||||
enc.AddString("remote_port", port)
|
enc.AddString("remote_port", port)
|
||||||
enc.AddString("client_ip", GetVar(r.Context(), ClientIPVarKey).(string))
|
if ip, ok := GetVar(r.Context(), ClientIPVarKey).(string); ok {
|
||||||
|
enc.AddString("client_ip", ip)
|
||||||
|
}
|
||||||
enc.AddString("proto", r.Proto)
|
enc.AddString("proto", r.Proto)
|
||||||
enc.AddString("method", r.Method)
|
enc.AddString("method", r.Method)
|
||||||
enc.AddString("host", r.Host)
|
enc.AddString("host", r.Host)
|
||||||
|
|
Loading…
Reference in New Issue