Skip to content

Commit

Permalink
feat: print x forward for
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Aug 7, 2024
1 parent bf3c5fc commit a57f098
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func MiddlewareCustomLogger(c *fiber.Ctx) error {
Str("user_agent", c.Get("User-Agent", "")).
Int64("latency", latency).
Str("content_type", contentType)

xForwardFor := c.Get("X-Forwarded-For")
if xForwardFor != "" {
output = output.Str("x_forwarded_for", xForwardFor)
}
if ok {
output = output.Int("user_id", userID)
}
Expand Down

0 comments on commit a57f098

Please sign in to comment.