Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
jsonrpsee
Commits
50725dca
Unverified
Commit
50725dca
authored
Jul 25, 2022
by
Alexandru Vasile
Browse files
http: Implement equivalent of `make_service_fn`
Signed-off-by:
Alexandru Vasile
<
alexandru.vasile@parity.io
>
parent
aa0936ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
http-server/src/server.rs
View file @
50725dca
...
...
@@ -554,6 +554,30 @@ impl<M: Middleware> hyper::service::Service<hyper::Request<hyper::Body>> for RPS
}
}
/// JsonRPSee service compatible with `tower`.
///
/// # Note
/// This is similar to [`hyper::service::make_service_fn`].
pub
struct
RPSeeServerMakeSvc
<
M
>
{
inner
:
RPSeeSvcData
<
M
>
,
}
impl
<
T
,
M
:
Clone
+
Send
+
'static
>
hyper
::
service
::
Service
<
T
>
for
RPSeeServerMakeSvc
<
M
>
{
type
Response
=
RPSeeServerSvc
<
M
>
;
type
Error
=
hyper
::
Error
;
type
Future
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
Self
::
Response
,
Self
::
Error
>>
+
Send
>>
;
fn
poll_ready
(
&
mut
self
,
_
:
&
mut
Context
)
->
Poll
<
Result
<
(),
Self
::
Error
>>
{
Poll
::
Ready
(
Ok
(()))
}
fn
call
(
&
mut
self
,
_connection
:
T
)
->
Self
::
Future
{
let
inner
=
self
.inner
.clone
();
let
fut
=
async
move
{
Ok
(
RPSeeServerSvc
{
inner
})
};
Box
::
pin
(
fut
)
}
}
/// An HTTP JSON RPC server.
#[derive(Debug)]
pub
struct
Server
<
M
=
()
>
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment