-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 Log request headers in logger middleware #1532
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
I think that makes sense if the default logging format would be JSON, not plain text as it is right now. Frankly, I don't know how to implement that in a readable manner in plain text, or how to enforce the JSON in the current implementation... Am I wrong about that? |
I think there is no standard for logging format, but I prefer single-line json string for request logging. headers := make(map[string]string)
c.Request().Header.VisitAll(func(k, v []byte) {
headers[string(k)] = string(v)
})
headersBuffer, _ := json.Marshal(headers)
_ = c.Locals("headers", headersBuffer) |
What about the |
Is this still applicable? Looks like there's already a |
Is your feature request related to a problem?
Yes. I want to log whole request headers using
logger
middleware.Describe the solution you'd like
A new template tag could be added and support the feature logging all request headers.
Additional context
According to #1148, I can only get all headers using fasthttp's functions. Maybe it is also good to add a function for fiber context.
The text was updated successfully, but these errors were encountered: