ResponseParts::new to use Axum response extensions in custom tower service #1385
-
Feature RequestMotivationToday we have a very useful RequestParts::new to leverage Axum request extractors from tower services. At the moment I am implementing an authentication layer and was looking to rely on axum-cookies. I can trivially extract CookieJar from RequestParts::new, but after processing authentication and awaiting for response, I cannot re-inject the modified CookieJar from the service layer. I'm sure there are other potential IntoResponseParts applications that could be useful from intermediate layers. ProposalI believe a trivial RequestParts::new method would address this use case. AlternativesPotentially removing (crate) restriction on inner of ResponseParts would accomplish the same goal but probably would be less consistent with RequestParts. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can do (cookie_jar, response).into_response() And return that from your |
Beta Was this translation helpful? Give feedback.
-
That worked. |
Beta Was this translation helpful? Give feedback.
You can do
And return that from your
Service
.