-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
28 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,27 @@ | ||
use std::marker::PhantomData; | ||
|
||
use crate::{async_trait, Handler, IntoResponse, Response, Result}; | ||
|
||
/// Maps the handler's output type to the [`Response`]. | ||
#[derive(Debug)] | ||
pub struct MapInToResponse<H, O>(pub(crate) H, PhantomData<O>); | ||
#[derive(Debug, Clone)] | ||
pub struct MapInToResponse<H>(pub(crate) H); | ||
|
||
impl<H, O> MapInToResponse<H, O> { | ||
impl<H> MapInToResponse<H> { | ||
/// Creates a new `Responder`. | ||
#[inline] | ||
pub(super) fn new(h: H) -> Self { | ||
Self(h, PhantomData) | ||
} | ||
} | ||
|
||
impl<H, O> Clone for MapInToResponse<H, O> | ||
where | ||
H: Clone, | ||
{ | ||
fn clone(&self) -> Self { | ||
Self(self.0.clone(), PhantomData) | ||
Self(h) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl<H, I, O> Handler<I> for MapInToResponse<H, O> | ||
impl<H, I, O> Handler<I> for MapInToResponse<H> | ||
where | ||
I: Send + 'static, | ||
H: Handler<I, Output = Result<O>> + Clone, | ||
O: IntoResponse + Send + Sync + 'static, | ||
O: IntoResponse + Send, | ||
{ | ||
type Output = Result<Response>; | ||
|
||
async fn call(&self, args: I) -> Self::Output { | ||
self.0.call(args).await.map(IntoResponse::into_response) | ||
async fn call(&self, i: I) -> Self::Output { | ||
self.0.call(i).await.map(IntoResponse::into_response) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters