I am using a request interceptor to perform JWT validation and decoding. I need to pass the decoded custom JWT information from the Interceptor to the resource endpoint (service.bal). I have identified that there are 2 possible ways to do this. Passing through a http:RequestContext Passing through a http:Request I just wanted to clarify which way is the ideal way for the above requirement and the reason for it.
public type JwtRecord record {|
string email;
string[] roles;
|}
The request context serves the purpose of sharing contextual information throughout the request-response path. Therefore, using a request context is ideal here, rather than unnecessarily creating a request object. You can set the value in the context like this:
And retrieve the info from the context like this: