I cannot successfully modify the response in middleware #2970
Unanswered
SpaceAceMonkey
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Edit: I started over with the middleware example, added the
into_parts()
code, then fixed errors one at a time. It appears to be working, now, but I have absolutely no idea what is different this time than the previous time(s) I tried copy/pasting the middleware example from the documentation, or from the issue I linked to, below. I think the documentation needs a working example of modifying the response. If it exists, I was unable to find it.I am using actix-web 4.3.0.
I am having a nightmare of a time modifying the response in middleware. At first, I based my effort on the middleware example in the documentation, but when I tried to adapt that example by creating a new
ServiceResponse
, I would up in type-error hell. I managed to solve some of the issues by using a concrete type in place of theB
generic in the middleware, but I still had problems with theHttpResponse
and theServiceResponse
not getting along.Finally, I found this discussion: 2834. I changed my code to extract the pieces from
res
as shown on that page, and I managed to get the code to compile, but now I have a new problem. Whether I use an annotation, or.wrap()
, I am now receiving this error:I finally tried copy/pasting the completed middleware from the linked discussion, but I am still having this issue. My code is currently identical to the code from 2834, minus the
redis
stuff, and with theok()
added to the unwrap as discussed on that page.Beta Was this translation helpful? Give feedback.
All reactions