mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-26 13:43:47 +03:00
caddyhttp: Fix panic when request missing ClientIPVarKey (#6040)
This commit is contained in:
parent
750d0b8331
commit
f5344f8cad
1 changed files with 3 additions and 1 deletions
|
@ -40,7 +40,9 @@ func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
|||
|
||||
enc.AddString("remote_ip", ip)
|
||||
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("method", r.Method)
|
||||
enc.AddString("host", r.Host)
|
||||
|
|
Loading…
Reference in a new issue