[][src]Struct actix_web::web::Form

pub struct Form<T>(pub T);

Form data helper (application/x-www-form-urlencoded)

Can be use to extract url-encoded data from the request body, or send url-encoded data as the response.


To extract typed information from request's body, the type T must implement the Deserialize trait from serde.

FormConfig allows to configure extraction process.


#[macro_use] extern crate serde_derive;
use actix_web::{web, App};

struct FormData {
    username: String,

/// Extract form data using serde.
/// This handler get called only if content type is *x-www-form-urlencoded*
/// and content of the request could be deserialized to a `FormData` struct
fn index(form: web::Form<FormData>) -> String {
    format!("Welcome {}!", form.username)


The Form type also allows you to respond with well-formed url-encoded data: simply return a value of type Form where T is the type to be url-encoded. The type must implement serde::Serialize;


struct SomeForm {
    name: String,
    age: u8

// Will return a 200 response with header
// `Content-Type: application/x-www-form-urlencoded`
// and body "name=actix&age=123"
fn index() -> web::Form<SomeForm> {
    web::Form(SomeForm {
        name: "actix".into(),
        age: 123


impl<T> Form<T>[src]

pub fn into_inner(self) -> T[src]

Deconstruct to an inner value

Trait Implementations

impl<T> FromRequest for Form<T> where
    T: DeserializeOwned + 'static, 

type Config = FormConfig

Configuration for this extractor

type Error = Error

The associated error which can be returned.

type Future = Box<dyn Future<Item = Self, Error = Error>>

Future that resolves to a Self

fn extract(req: &HttpRequest) -> Self::Future[src]

Convert request to a Self Read more

fn configure<F>(f: F) -> Self::Config where
    F: FnOnce(Self::Config) -> Self::Config

Create and configure config instance.

impl<T: Serialize> Responder for Form<T>[src]

type Error = Error

The associated error which can be returned.

type Future = Result<Response, Error>

The future response value.

fn with_status(self, status: StatusCode) -> CustomResponder<Self> where
    Self: Sized

Override a status code for a Responder. Read more

fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self> where
    Self: Sized,
    HeaderName: HttpTryFrom<K>,
    V: IntoHeaderValue

Add header to the Responder's response. Read more

impl<T: Ord> Ord for Form<T>[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<T: Eq> Eq for Form<T>[src]

impl<T: PartialOrd> PartialOrd<Form<T>> for Form<T>[src]

impl<T: PartialEq> PartialEq<Form<T>> for Form<T>[src]

impl<T> DerefMut for Form<T>[src]

impl<T: Debug> Debug for Form<T>[src]

impl<T: Display> Display for Form<T>[src]

impl<T> Deref for Form<T>[src]

type Target = T

The resulting type after dereferencing.

Auto Trait Implementations

impl<T> Send for Form<T> where
    T: Send

impl<T> Sync for Form<T> where
    T: Sync

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized

impl<T> Erased for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,