Open mason-liu opened 1 year ago
so you're using httplog.RequestLogger in addition adding middleware.RequestID separately..?
@mason-liu you can use the httplog.Handler as a middleware instead of httplog.RequestLogger, if you are already using the RequestID and Recoverer middlewares: https://github.com/go-chi/httplog/blob/a414fec0944146d5f63a935c9ad45975f2c09ce7/httplog.go#L57
Please have a look at https://github.com/go-chi/traceid. It's an alternative to middleware.RequestID, which handles multiple uses well and also adds service-to-service tracing capabilities.
If the request id middleware is called several times for one request, each time it will generate new request id. I have this issue because httplog.RequestLogger enables request id middleware by default and no way to remove. The expected result is, request id should only be generated once for each request even it is called several times, 2 ways I think: