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
|
|
|
|
2019-06-26 01:27:17 -04:00
|
|
|
pub fn index(payload: web::Payload) -> Box<Future<Item = HttpResponse, Error = Error>> {
|
|
|
|
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();
|
|
|
|
}
|