You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you for the great project. I use it in all my net core projects.
I have a unique situation where I need to integrate with legacy APIs and cannot change the source. Our new APIs use the the standard x-correlation-id header and older APIs use a different header. I need the ability to first try reading x-correlation-id and then fallback to old header name.
Are you open to extending the middleware via the CorrelationIdOptions by adding a callback property
/// <summary>/// A callback to resolve the correlation ID. /// </summary>publicFunc<IHeaderDictionary,StringValues>RequestHeaderCallback{ get; set;}
This simple change would allow users to use custom logic to read the correlation header. I can even make the callback more broad by passing the HttpContext and maybe even IServiceProvider in case people need to use DI to get their correlation id value.
Happy to submit a PR.
The text was updated successfully, but these errors were encountered:
Hi @dashkan. Thanks for raising this suggestion and the offer of a PR!
This feels like a useful addition for situations such as yours. I'm wondering if it would be enough to simply support an array of header names to attempt to read, with the first match returning the correlation ID?
If I may suggest, this could be also done by providing sequence of headers to be used when reading correlation ID, and then simply iterating over it and trying to find given header in request. Assuming that such iteration won't be expensive since you will configure just few headers, and lookup in HttpRequest.Headers is cheap as it is dictionary.
First of all, thank you for the great project. I use it in all my net core projects.
I have a unique situation where I need to integrate with legacy APIs and cannot change the source. Our new APIs use the the standard x-correlation-id header and older APIs use a different header. I need the ability to first try reading x-correlation-id and then fallback to old header name.
Are you open to extending the middleware via the CorrelationIdOptions by adding a callback property
And update the middleware
This simple change would allow users to use custom logic to read the correlation header. I can even make the callback more broad by passing the HttpContext and maybe even IServiceProvider in case people need to use DI to get their correlation id value.
Happy to submit a PR.
The text was updated successfully, but these errors were encountered: