Add data to RequestContext

Dear experts,

I am wondering if it is possible to make data of any kind available to custom downstream directives without explicitly passing them as parameters to the respective functions?
The only “solution” I came up so far was to use mapRequest() and add the parameter as an “X-” header to the HttpRequest … but that is definitely too much of a hack :slight_smile:

How would you do that?

Thanks, Felix

1 Like

Hello,
Did you find any solution?

Since 10.2.x you can use request attributes for this purpose. There’s not yet a dedicated directive but you should be able to use something like mapRequest(_.addAttribute(...)).

Thank you for your answer.
I want use request context as a request scoped object container for trace, metrics, etc. I tried to extend request context class, but somehow it restores in other directives.
I will be glad for any help or advice.