Skip to content

Middleware Response body manipulation #3283

Closed Answered by 0rangeFox
0rangeFox asked this question in Q&A
Discussion options

You must be logged in to vote

Ooohhh yeah, I managed to get everything working with the help of @robjtede, if it wasn't for him it might have taken me longer to get there. Basically, most of the problem I had was that I was restricting the generic type B to be a MessageBody, so if we look at the struct ServiceResponse, the generic type is already defined as a BoxBody and that makes it even better than defining our generic types, making it dynamic and being able to manipulate any types we want. So for those interested who want to know what the solution looks like with the full code, here goes! Happy coding! 💪

use std::future::{Future, ready, Ready};
use std::pin::Pin;
use std::rc::Rc;
use actix_web::{dev::{forward_ready, 

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@robjtede
Comment options

Comment options

You must be logged in to vote
6 replies
@0rangeFox
Comment options

@robjtede
Comment options

@0rangeFox
Comment options

@robjtede
Comment options

@0rangeFox
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by 0rangeFox
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
Converted from issue

This discussion was converted from issue #3282 on February 06, 2024 03:10.