Replies: 1 comment
-
There's only one body which may be a stream so you cannot consume it multiple times. What you can do is combine the two extractors with something like #[derive(Debug, Clone, PartialEq)]
pub enum TurnstileResult<T> {
Allowed(T),
Denied,
} And in its implementation you can check cloudflare and then return the deserialized body. Another option would be collecting the body and then using it directly which I assume is what you meant by buffering. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Is there a way to extract something from request body without consuming the body and request itself? Im stuck because I have 2 FromRequest extractors that both want access to req body. I was told that you can achieve that with buffering but its less than perfect solution for me, mainly because of the complexity.
Details of my problem:
let's say I have a following body:
I want to run one extractor to verify the "captcha-code" by performing an http request to cloudflare, then the 2nd extractor would extract user info from the same body.
part of my captcha extractor:
part of my user extractor:
The endpoint bellow doesnt compile, error (#[axum::debug_handler doesn't help):
endpoint:
axum version
version = "0.7.5"
Beta Was this translation helpful? Give feedback.
All reactions