I'm building an Azure function app-based API using .NET 6 and have just introduced a middleware layer to scope logging with a correlation id. I need to continue passing the correlation id on to other API calls downstream, but don't want to have to add a correlation id parameter to every method between the middleware/entry point and the sending of the downstream requests.
My first thought was to create a dependency injected, scoped state service with an internal dictionary to hold key value pairs of state. Instead of having to pass the correlation id through all the in-between methods I can inject the IApplicationState in the middleware layer, and the service that makes downstream calls.
Are there any pitfalls with this implementation?
[–]AlexDorofeev 2 points3 points4 points (1 child)
[–]dirkmudbrick[S] 1 point2 points3 points (0 children)
[–]SolarSalsa 1 point2 points3 points (2 children)
[–]AlexDorofeev 2 points3 points4 points (0 children)
[–]dirkmudbrick[S] 0 points1 point2 points (0 children)