[][src]Struct actix_web::web::Payload

pub struct Payload(_);

Payload extractor returns request 's payload stream.

Example

use futures::{Future, Stream};
use actix_web::{web, error, App, Error, HttpResponse};

/// extract binary data from request
fn index(body: web::Payload) -> impl Future<Item = HttpResponse, Error = Error>
{
    body.map_err(Error::from)
        .fold(web::BytesMut::new(), move |mut body, chunk| {
            body.extend_from_slice(&chunk);
            Ok::<_, Error>(body)
         })
         .and_then(|body| {
             format!("Body {:?}!", body);
             Ok(HttpResponse::Ok().finish())
         })
}

fn main() {
    let app = App::new().service(
        web::resource("/index.html").route(
            web::get().to_async(index))
    );
}

Trait Implementations

impl FromRequest for Payload[src]

Get request's payload stream

Example

use futures::{Future, Stream};
use actix_web::{web, error, App, Error, HttpResponse};

/// extract binary data from request
fn index(body: web::Payload) -> impl Future<Item = HttpResponse, Error = Error>
{
    body.map_err(Error::from)
        .fold(web::BytesMut::new(), move |mut body, chunk| {
            body.extend_from_slice(&chunk);
            Ok::<_, Error>(body)
         })
         .and_then(|body| {
             format!("Body {:?}!", body);
             Ok(HttpResponse::Ok().finish())
         })
}

fn main() {
    let app = App::new().service(
        web::resource("/index.html").route(
            web::get().to_async(index))
    );
}

type Config = PayloadConfig

Configuration for this extractor

type Error = Error

The associated error which can be returned.

type Future = Result<Payload, Error>

Future that resolves to a Self

impl Stream for Payload[src]

type Item = Bytes

The type of item this stream will yield on success.

type Error = PayloadError

The type of error this stream may generate.

Auto Trait Implementations

impl !Send for Payload

impl Unpin for Payload

impl !Sync for Payload

impl !UnwindSafe for Payload

impl !RefUnwindSafe for Payload

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

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

impl<T> Erased for T

impl<T> IntoStream for T where
    T: Stream
[src]

type Item = <T as Stream>::Item

type Error = <T as Stream>::Error

type Stream = T

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