pub struct Form<T>(pub T);
Expand description
Extractor that deserializes application/x-www-form-urlencoded
requests
into some type.
T
is expected to implement serde::Deserialize
.
Example
use axum::{
extract::Form,
routing::post,
Router,
};
use serde::Deserialize;
#[derive(Deserialize)]
struct SignUp {
username: String,
password: String,
}
async fn accept_form(form: Form<SignUp>) {
let sign_up: SignUp = form.0;
// ...
}
let app = Router::new().route("/sign_up", post(accept_form));
Note that Content-Type: multipart/form-data
requests are not supported.
Tuple Fields
0: T
Trait Implementations
type Rejection = FormRejection
type Rejection = FormRejection
If the extractor fails it’ll use this “rejection” type. A rejection is a kind of error that can be converted into a response. Read more
fn from_request<'life0, 'async_trait>(
req: &'life0 mut RequestParts<B>
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Rejection>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn from_request<'life0, 'async_trait>(
req: &'life0 mut RequestParts<B>
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Rejection>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Perform the extraction.
Auto Trait Implementations
impl<T> RefUnwindSafe for Form<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Form<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Create a new Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more