Trait prost_twirp::HyperService
source · pub trait HyperService {
fn handle(
&self,
req: Request<Body>
) -> Pin<Box<dyn Future<Output = Result<Response<Body>, ProstTwirpError>> + Send>>;
}
Expand description
A trait for the heart of a Twirp service: responding to every service method.
Implementations are responsible for:
- Matching the URL to a service method (or returning a 404).
- Decoding the request body into a protobuf message, typically using ServiceRequest::from_hyper_request for the appropriate message.
- Calling the application logic to handle the request.
- Encoding the response into a protobuf message, typically using ServiceResponse::to_hyper_response.
An implementation of this trait is generated by the service-gen
integration, or it can be implemented manually.