mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-24 00:00:16 +02:00
Don't force handlers to return Results
This commit is contained in:
@@ -7,6 +7,15 @@ pub trait IntoResponse<B> {
|
||||
fn into_response(self) -> Result<Response<B>, Error>;
|
||||
}
|
||||
|
||||
impl<B, T> IntoResponse<B> for Result<T, Error>
|
||||
where
|
||||
T: IntoResponse<B>,
|
||||
{
|
||||
fn into_response(self) -> Result<Response<B>, Error> {
|
||||
self.and_then(IntoResponse::into_response)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> IntoResponse<B> for Response<B> {
|
||||
fn into_response(self) -> Result<Response<B>, Error> {
|
||||
Ok(self)
|
||||
|
||||
Reference in New Issue
Block a user