Skip to content

Coercing HttpResponse into HttpRespnose<B> #3438

Answered by robjtede
harr1424 asked this question in Q&A
Discussion options

You must be logged in to vote

Kinda duplicate of #3428

You can't coerce something to a B here any more than other generics in Rust.

You're on the right track using EitherBody and the helper methods. The missing piece is in the return type:

) -> Result<ServiceResponse<EitherBody<B>>, Error>

In essensce, you're wrapping a Svc(ResponseBody = B) into a Svc(ResponseBody = EitherBody<B, BoxBody>), where B is still only from the service.call(req).await result, and BoxBody is from your other responses.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@harr1424
Comment options

@robjtede
Comment options

@harr1424
Comment options

@robjtede
Comment options

Answer selected by robjtede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants