Module handler

Module handler 

Source
Expand description

This module provides traits and structs that relate to the handler functions that we can pass to API routes.

Re-exports§

pub use body::HandlerBody;
pub use response::HandlerResponse;

Modules§

body
This contains the HandlerBody trait, which you can implement on a type in order to allow it to be used at a parameter in a handler function which can extract data from the request body. A couple of convenience types (body::FromJson and body::FromBinary) are exposed which implement this trait.
request
This contains helpers around the body that you’ll need to provide as part of an http::Request, mainly geared around allowing requests to be streamed in if desired. This module provides some functionality for creating a valid request body to send to Seamless as part of an http::Request. Essentially, anything implementing AsyncRead + Send + Unpin can be provided as a request body, but this module provides a Bytes struct which can easily convert a Vec<u8> or futures::Stream into such a body.
response
This contains the HandlerResponse trait, which determines how to form an HTTP response given some type. Implement this for types that you wish to be able to return from handler functions.

Traits§

HandlerParam
Implement this for anything that you want to be able to pass into a request handler that doesn’t want to consume the body of the request. This is useful for implementing request guards which prevent the handler from being called unless specific conditions are met (for instance a user is logged in).