Module hyper::service [] [src]

Services and NewServices

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.

NewService

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 NewService does.

Resources that need to be shared by all Services can be put into a NewService, and then passed to individual Services when new_service is called.

Traits

NewService

An asynchronous constructor of Services.

Service

An asynchronous function from Request to Response.

Functions

service_fn

Create a Service from a function.

service_fn_ok

Create a Service from a function that never errors.