1
0
mirror of https://github.com/actix/actix-website synced 2025-02-13 00:25:35 +01:00

27 lines
705 B
Rust
Raw Normal View History

2019-06-17 14:34:23 -04:00
// <streaming>
2019-06-26 01:27:17 -04:00
use actix_web::{error, web, Error, HttpResponse};
use futures::{future::result, Future, Stream};
2019-06-17 14:34:23 -04:00
pub fn index(payload: web::Payload) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {
2019-06-26 01:27:17 -04:00
Box::new(
payload
.from_err()
.fold((), |_, chunk| {
println!("Chunk: {:?}", chunk);
result::<_, error::PayloadError>(Ok(()))
})
.map(|_| HttpResponse::Ok().into()),
)
}
2019-06-17 14:34:23 -04:00
// </streaming>
2019-06-26 01:27:17 -04:00
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| App::new().route("/", web::post().to_async(index)))
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
}