http server: propagate extensions in http response #1514
+182
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #1509
This PR propagates the extensions set by the RPC middleware such that users can inspect them via HTTP middleware and perhaps indicate a HTTP error or something.
The handling of batch requests are not ideal because because the if the same type is used more than once then the
most recent wins in the old data is overwritten. Because the http::Extensions works based on the rust type ids and it's not possible to merge two types in a clean way I think i.e, just overwrite them with the most recent one...
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
Vec<String>, Vec<usize>
and so on...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....
We could introduce another representation of the extensions internally and just merge them before constructing the response though...