Skip to content

Add map_response and friends #1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 25, 2022
Merged

Add map_response and friends #1414

merged 2 commits into from
Sep 25, 2022

Conversation

davidpdrsn
Copy link
Member

Part of #1394

Verified

This commit was signed with the committer’s verified signature.
issyl0 Issy Long
impl<F, Fut, S, I, B, ResBody, $($ty,)*> Service<Request<B>> for MapResponse<F, S, I, ($($ty,)*)>
where
F: FnMut($($ty,)* Response<ResBody>) -> Fut + Clone + Send + 'static,
$( $ty: FromRequestParts<S> + Send, )*
Copy link
Member Author

@davidpdrsn davidpdrsn Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we require FromRequestParts and not FromRequest. Not sure there would be a way to recover the request afterwards so we can pass it to the inner service 🤔

If users need the request body in a map_response I think a full from_fn might be more appropriate.

Copy link
Member

@jplatte jplatte Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is exactly right IMO.

@davidpdrsn davidpdrsn enabled auto-merge (squash) September 25, 2022 14:02
impl<F, Fut, S, I, B, ResBody, $($ty,)*> Service<Request<B>> for MapResponse<F, S, I, ($($ty,)*)>
where
F: FnMut($($ty,)* Response<ResBody>) -> Fut + Clone + Send + 'static,
$( $ty: FromRequestParts<S> + Send, )*
Copy link
Member

@jplatte jplatte Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is exactly right IMO.

@davidpdrsn davidpdrsn merged commit 04ef2f1 into main Sep 25, 2022
@davidpdrsn davidpdrsn deleted the map-response branch September 25, 2022 14:21
@jplatte
Copy link
Member

jplatte commented Sep 25, 2022

Oh, you had enabled auto-merge. Well, docs can still be improved separately :)

@davidpdrsn
Copy link
Member Author

Oh, you had enabled auto-merge. Well, docs can still be improved separately :)

🚀 😅

I'll do a follow-up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants