go-chi / go-chi/chi

Duplicate Request ID if Use middleware several times

Open
#825 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
22.9k
Forks
1.4k
Avg merge
5h 17m
Merged PRs (30d)
10

Description

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:
1. https://github.com/go-chi/chi/blob/master/middleware/request_id.go#L70 request ID should get from context instead of request header
2. Once generate new request ID, should add it to request header

Contributor guide

Open the contributing guide

Research direction

Start with middleware/request_id.go at the linked request ID handling, then reproduce a request passing through the middleware more than once, including httplog.RequestLogger. Confirm the expected behavior for repeated middleware use and verify that one request retains a single request ID without breaking the existing middleware behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.