[−][src]Trait mendes::application::Application
This is supported on crate feature
application
only.Main interface for an application or service
The Application
holds state and routes request to the proper handlers. A handler gets
an immutable reference to the Application
to access application state. Common usage
for this would be to hold a persistent storage connection pool.
The Application
also helps process handler reponses. It can handle errors and turn them
into HTTP responses, using the error()
method to transform the Error
associated type
into a Response
.
Associated Types
type RequestBody: Send
type ResponseBody: Send
type Error: Responder<Self> + WithStatus + From<Error> + Send
Required methods
#[must_use]fn handle<'async_trait>(
self: Arc<Self>,
req: Request<Self::RequestBody>
) -> Pin<Box<dyn Future<Output = Response<Self::ResponseBody>> + Send + 'async_trait>> where
Self: 'async_trait,
self: Arc<Self>,
req: Request<Self::RequestBody>
) -> Pin<Box<dyn Future<Output = Response<Self::ResponseBody>> + Send + 'async_trait>> where
Self: 'async_trait,
Provided methods
fn from_body_bytes<'de, T: Deserialize<'de>>(
req: &Parts,
bytes: &'de [u8]
) -> Result<T, Error>
req: &Parts,
bytes: &'de [u8]
) -> Result<T, Error>
#[must_use]fn from_body<'life0, 'async_trait, T: DeserializeOwned>(
req: &'life0 Parts,
body: Self::RequestBody
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>> where
Self::RequestBody: HttpBody + Send,
<Self::RequestBody as HttpBody>::Data: Send,
<Self::RequestBody as HttpBody>::Error: Into<Box<dyn StdError + Sync + Send>>,
T: 'async_trait,
'life0: 'async_trait,
Self: Send + 'async_trait,
req: &'life0 Parts,
body: Self::RequestBody
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>> where
Self::RequestBody: HttpBody + Send,
<Self::RequestBody as HttpBody>::Data: Send,
<Self::RequestBody as HttpBody>::Error: Into<Box<dyn StdError + Sync + Send>>,
T: 'async_trait,
'life0: 'async_trait,
Self: Send + 'async_trait,
This is supported on crate feature
with-http-body
only.#[must_use]fn body_bytes<'async_trait, B>(
body: B
) -> Pin<Box<dyn Future<Output = Result<Bytes, B::Error>> + Send + 'async_trait>> where
B: HttpBody + Send,
<B as HttpBody>::Data: Send,
B: 'async_trait,
body: B
) -> Pin<Box<dyn Future<Output = Result<Bytes, B::Error>> + Send + 'async_trait>> where
B: HttpBody + Send,
<B as HttpBody>::Data: Send,
B: 'async_trait,
This is supported on crate feature
with-http-body
only.fn redirect(status: StatusCode, path: &str) -> Response<Self::ResponseBody> where
Self::ResponseBody: Default,
Self::ResponseBody: Default,