Trait actix_web::FromRequest[][src]

pub trait FromRequest<S>: Sized {
    type Config: Default;
    type Result: Into<AsyncResult<Self>>;
    fn from_request(req: &HttpRequest<S>, cfg: &Self::Config) -> Self::Result;

    fn extract(req: &HttpRequest<S>) -> Self::Result { ... }
}

Trait implemented by types that can be extracted from request.

Types that implement this trait can be used with Route::with() method.

Associated Types

Configuration for conversion process

Future that resolves to a Self

Required Methods

Convert request to a Self

Provided Methods

Convert request to a Self

This method uses default extractor configuration

Implementations on Foreign Types

impl<S: 'static> FromRequest<S> for Bytes
[src]

Request payload extractor.

Loads request's payload and construct Bytes instance.

PayloadConfig allows to configure extraction process.

Example

extern crate bytes;
use actix_web::{http, App, Result};

/// extract text data from request
fn index(body: bytes::Bytes) -> Result<String> {
    Ok(format!("Body {:?}!", body))
}

fn main() {
    let app = App::new()
        .resource("/index.html", |r| r.method(http::Method::GET).with(index));
}

impl<S: 'static> FromRequest<S> for String
[src]

Extract text information from the request's body.

Text extractor automatically decode body according to the request's charset.

PayloadConfig allows to configure extraction process.

Example

use actix_web::{http, App, Result};

/// extract text data from request
fn index(body: String) -> Result<String> {
    Ok(format!("Body {}!", body))
}

fn main() {
    let app = App::new().resource("/index.html", |r| {
        r.method(http::Method::GET)
               .with_config(index, |cfg| { // <- register handler with extractor params
                  cfg.limit(4096);  // <- limit size of the payload
                })
    });
}

impl<S, A: FromRequest<S> + 'static> FromRequest<S> for (A,) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static> FromRequest<S> for (A, B) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static, C: FromRequest<S> + 'static> FromRequest<S> for (A, B, C) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static, C: FromRequest<S> + 'static, D: FromRequest<S> + 'static> FromRequest<S> for (A, B, C, D) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static, C: FromRequest<S> + 'static, D: FromRequest<S> + 'static, E: FromRequest<S> + 'static> FromRequest<S> for (A, B, C, D, E) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static, C: FromRequest<S> + 'static, D: FromRequest<S> + 'static, E: FromRequest<S> + 'static, F: FromRequest<S> + 'static> FromRequest<S> for (A, B, C, D, E, F) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static, C: FromRequest<S> + 'static, D: FromRequest<S> + 'static, E: FromRequest<S> + 'static, F: FromRequest<S> + 'static, G: FromRequest<S> + 'static> FromRequest<S> for (A, B, C, D, E, F, G) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static, C: FromRequest<S> + 'static, D: FromRequest<S> + 'static, E: FromRequest<S> + 'static, F: FromRequest<S> + 'static, G: FromRequest<S> + 'static, H: FromRequest<S> + 'static> FromRequest<S> for (A, B, C, D, E, F, G, H) where
    S: 'static, 
[src]

FromRequest implementation for tuple

impl<S, A: FromRequest<S> + 'static, B: FromRequest<S> + 'static, C: FromRequest<S> + 'static, D: FromRequest<S> + 'static, E: FromRequest<S> + 'static, F: FromRequest<S> + 'static, G: FromRequest<S> + 'static, H: FromRequest<S> + 'static, I: FromRequest<S> + 'static> FromRequest<S> for (A, B, C, D, E, F, G, H, I) where
    S: 'static, 
[src]

FromRequest implementation for tuple

Implementors