1
0
mirror of https://github.com/actix/actix-website synced 2025-02-08 22:36:07 +01:00

25 lines
640 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};
2019-12-29 02:32:47 +09:00
use futures::{Future, Stream, StreamExt};
2019-06-17 14:34:23 -04:00
2019-12-29 02:32:47 +09:00
async fn index(mut body: web::Payload) -> Result<HttpResponse, Error> {
let mut bytes = web::BytesMut::new();
while let Some(item) = body.next().await {
bytes.extend_from_slice(&item?);
}
println!("Chunk: {:?}", bytes);
Ok(HttpResponse::Ok().finish())
2019-06-26 01:27:17 -04:00
}
2019-06-17 14:34:23 -04:00
// </streaming>
2019-06-26 01:27:17 -04:00
2019-12-29 02:32:47 +09:00
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
2019-06-26 01:27:17 -04:00
use actix_web::{App, HttpServer};
2019-12-29 02:32:47 +09:00
HttpServer::new(|| App::new().route("/", web::post().to(index)))
.bind("127.0.0.1:8088")?
2019-06-26 01:27:17 -04:00
.run()
2019-12-29 02:32:47 +09:00
.await
2019-06-26 01:27:17 -04:00
}