Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 18:15 UTC
caddyhttp: Fix panic when request missing ClientIPVarKey (#6040)
Francis Lavoie committed
Jan 23, 2024 at 19:45 UTC
f5344f8caddee53cebe249712ba7803e22abf9f1
1 file changed
+3
-1
modules/caddyhttp/marshalers.go
+3
-1
@@ -40,7 +40,9 @@ func (r LoggableHTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error {
40
41
enc.AddString("remote_ip", ip)
42
enc.AddString("remote_port", port)
43
- enc.AddString("client_ip", GetVar(r.Context(), ClientIPVarKey).(string))
43
+ if ip, ok := GetVar(r.Context(), ClientIPVarKey).(string); ok {
44
+ enc.AddString("client_ip", ip)
45
+ }
46
enc.AddString("proto", r.Proto)
47
enc.AddString("method", r.Method)
48
enc.AddString("host", r.Host)