How to modify the Payload
of ServiceRequest
in custom middleware
#1849
Answered
by
robjtede
new-commer
asked this question in
Q&A
-
I want to modify the Payload of ServiceRequest in function
|
Beta Was this translation helpful? Give feedback.
Answered by
robjtede
Dec 23, 2020
Replies: 2 comments 1 reply
-
I guarantee payload is JSON data. |
Beta Was this translation helpful? Give feedback.
0 replies
-
There's a trick we use internally for it in the Either extractor: fn payload_from_bytes(bytes: Bytes) -> dev::Payload {
let (_, mut h1_payload) = actix_http::h1::Payload::create(true);
h1_payload.unread_data(bytes);
dev::Payload::from(h1_payload)
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
robjtede
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a trick we use internally for it in the Either extractor: