reth_rpc_builder/
middleware.rs1use jsonrpsee::server::{
2 middleware::rpc::RpcService, HttpRequest, HttpResponse, TowerServiceNoHttp,
3};
4use tower::{
5 layer::util::{Identity, Stack},
6 Layer,
7};
8
9pub trait RethRpcMiddleware:
11 Layer<
12 RpcService,
13 Service: jsonrpsee::server::middleware::rpc::RpcServiceT<
14 MethodResponse = jsonrpsee::MethodResponse,
15 BatchResponse = jsonrpsee::MethodResponse,
16 NotificationResponse = jsonrpsee::MethodResponse,
17 > + Send
18 + Sync
19 + Clone
20 + 'static,
21 > + Clone
22 + Send
23 + 'static
24{
25}
26
27impl<T> RethRpcMiddleware for T where
28 T: Layer<
29 RpcService,
30 Service: jsonrpsee::server::middleware::rpc::RpcServiceT<
31 MethodResponse = jsonrpsee::MethodResponse,
32 BatchResponse = jsonrpsee::MethodResponse,
33 NotificationResponse = jsonrpsee::MethodResponse,
34 > + Send
35 + Sync
36 + Clone
37 + 'static,
38 > + Clone
39 + Send
40 + 'static
41{
42}
43
44pub type AuthHttpService<RM> = TowerServiceNoHttp<Stack<RM, Identity>>;
46
47pub trait RethAuthHttpMiddleware<RM>:
49 tower::Layer<
50 AuthHttpService<RM>,
51 Service: tower::Service<
52 HttpRequest,
53 Response = HttpResponse,
54 Error = tower::BoxError,
55 Future: Send,
56 > + Send
57 + Clone,
58 > + Clone
59 + Send
60 + 'static
61{
62}
63
64impl<T, RM> RethAuthHttpMiddleware<RM> for T where
65 T: tower::Layer<
66 AuthHttpService<RM>,
67 Service: tower::Service<
68 HttpRequest,
69 Response = HttpResponse,
70 Error = tower::BoxError,
71 Future: Send,
72 > + Send
73 + Clone,
74 > + Clone
75 + Send
76 + 'static
77{
78}