You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm interesting in body_peek filter because it will make it easy to implement JSON RPC filters.
What I'd like to implement
let add_rpc_filter = json_rpc::method("add")// matches "add" rpc method.and(json_rpc::params::<(u8,u8)>())// matches rpc parameter.and(authenticate())// some user defined filter.and_then(|a, b| future::ok(a + b)).and_then(json_rpc::reply());let another_rpc_filter = ...;let rpc_filter = filters::path::("rpc").and(add_rpc_filter.or(another_rpc_filter));
The hard part
json_rpc::method and json_rpc::params filters need to access Body. But it will panic when Body is accessed more than once.
Ideas to solve it
To access Body using filters::body::body_peek or filters::body::json_peek filter.
Such filter allow us to access Body more than once.
Add extension to store extracted Body data.
Perhaps, this is better than above but I'm not sure how to do it without direct use of hyper.
According to Consider removal of warp::ext::set #222 , I should use Service directory and if my understand is correct, I should provide the mechanism almost same with warp's server module by myself. Is it right?
Do you have any ideas?
I probably don't understand warp enough. So if you let me know another idea, I'm very very happy!
Thank you!
The text was updated successfully, but these errors were encountered:
I have created PR #457 but it might have some issues...
So for now, I personally use custom Service which wraps FilteredService. It seems to work well :)
I'm interesting in
body_peek
filter because it will make it easy to implement JSON RPC filters.What I'd like to implement
The hard part
json_rpc::method
andjson_rpc::params
filters need to accessBody
. But it will panic whenBody
is accessed more than once.Ideas to solve it
To access
Body
usingfilters::body::body_peek
orfilters::body::json_peek
filter.Such filter allow us to access
Body
more than once.Add extension to store extracted
Body
data.Perhaps, this is better than above but I'm not sure how to do it without direct use of
hyper
.According to Consider removal of
warp::ext::set
#222 , I should useService
directory and if my understand is correct, I should provide the mechanism almost same with warp's server module by myself. Is it right?Do you have any ideas?
I probably don't understand warp enough. So if you let me know another idea, I'm very very happy!
Thank you!
The text was updated successfully, but these errors were encountered: