1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 18:44:35 +01:00

fix guide example

This commit is contained in:
Nikolay Kim 2018-02-26 16:41:57 -08:00
parent abae65a49e
commit 0ab8bc11f3

View File

@ -169,15 +169,18 @@ get enabled automatically.
Enabling chunked encoding for *HTTP/2.0* responses is forbidden. Enabling chunked encoding for *HTTP/2.0* responses is forbidden.
```rust ```rust
# extern crate bytes;
# extern crate actix_web; # extern crate actix_web;
# extern crate futures; # extern crate futures;
# use futures::Stream; # use futures::Stream;
use actix_web::*; use actix_web::*;
use bytes::Bytes;
use futures::stream::once;
fn index(req: HttpRequest) -> HttpResponse { fn index(req: HttpRequest) -> HttpResponse {
HttpResponse::Ok() HttpResponse::Ok()
.chunked() .chunked()
.body(Body::Streaming(Box::new(payload::Payload::empty().from_err()))).unwrap() .body(Body::Streaming(Box::new(once(Ok(Bytes::from_static(b"data")))))).unwrap()
} }
# fn main() {} # fn main() {}
``` ```