-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass response contexts from RPC middleware to HTTP middleware #1509
Comments
I think we could copy the extensions from the MethodResponse to the HTTP response to fix that and then you would need some HTTP middleware to check whether some error occurred and set desired HTTP status code on the response. This shouldn't be that hard to fix |
That would be really helpful. Thank you so much. |
Yeah, that one is tricky because the I had in mind that the user could inject a Vec or another collection that each call RPC call/request can push to it but we can't do that internally in jsonrpsee without some hacks like merging the rust collection types ourselves such as For now, I don't have a good solution except make user responsible to "inject unique types" because it may be overwritten in a batch but annoying.... |
Thank you so much for updates. I think overwriting is good practical options under the current situation. If users want to use AnyMap from jsonrpsee in hyper http layer, they can iterate over |
Yes, that would work but I propose we go ahead with this simple approach first i.e, just overwrite but worth looking into replacing the http::Extensions for a nicer API for batches such for users to append to that collection instead of overwriting. |
I agree. My implementation now depends on your PR branch and working good. Thank you so much |
I am developing a rate-limiting RPC middleware. Currently, jsonrpsee framework utilizes
MethodResponse
Extensions in the RPC layer andhttp::Response
Extensions in the HTTP layer, with these extensions operating independently of each other.I would like to propagate context information from the RPC layer to the HTTP layer to achieve functionality such as returning a status code other than 200 (429 in my case) or, at the very least, adding an HTTP header to indicate rate limiting based on data in contexts.
What would be the best approach to transfer context (Extensions) information from a jsonrpsee RPC middleware to a hyper HTTP middleware?
The text was updated successfully, but these errors were encountered: