1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-12-01 02:44:37 +01:00

fix guide examples

This commit is contained in:
Nikolay Kim 2018-02-26 08:02:58 -08:00
parent 0a3b776aa7
commit 56ae565688

View File

@ -106,10 +106,10 @@ use futures::{Future, Stream};
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
struct MyObj {name: String, number: i32} struct MyObj {name: String, number: i32}
fn index(mut req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> { fn index(req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
// `concat2` will asynchronously read each chunk of the request body and // `concat2` will asynchronously read each chunk of the request body and
// return a single, concatenated, chunk // return a single, concatenated, chunk
req.payload_mut().concat2() req.concat2()
// `Future::from_err` acts like `?` in that it coerces the error type from // `Future::from_err` acts like `?` in that it coerces the error type from
// the future into the final error type // the future into the final error type
.from_err() .from_err()
@ -170,12 +170,14 @@ Enabling chunked encoding for *HTTP/2.0* responses is forbidden.
```rust ```rust
# extern crate actix_web; # extern crate actix_web;
# extern crate futures;
# use futures::Stream;
use actix_web::*; use actix_web::*;
fn index(req: HttpRequest) -> HttpResponse { fn index(req: HttpRequest) -> HttpResponse {
HttpResponse::Ok() HttpResponse::Ok()
.chunked() .chunked()
.body(Body::Streaming(payload::Payload::empty().stream())).unwrap() .body(Body::Streaming(Box::new(payload::Payload::empty().from_err()))).unwrap()
} }
# fn main() {} # fn main() {}
``` ```