[−][src]Module hyper::service
Services and MakeServices
- A
Service
is a trait representing an asynchronous function of a request to a response. It's similar toasync fn(Request) -> Result<Response, Error>
. - A
MakeService
is a trait creating specific instances of aService
.
These types are conceptually similar to those in tower, while being specific to hyper.
Service
In hyper, especially in the server setting, a Service
is usually bound
to a single connection. It defines how to respond to all requests that
connection will receive.
While it's possible to implement Service
for a type manually, the helpers
service_fn
and
service_fn_ok
should be sufficient for most
cases.
MakeService
Since a Service
is bound to a single connection, a Server
needs a way to make them as it accepts connections. This is what a
MakeService
does.
Resources that need to be shared by all Service
s can be put into a
MakeService
, and then passed to individual Service
s when make_service
is called.
Traits
MakeService | An asynchronous constructor of |
Service | An asynchronous function from |
Functions
make_service_fn | Create a |
service_fn | Create a |
service_fn_ok | Create a |