1
0
mirror of https://github.com/actix/actix-website synced 2025-02-09 23:05:37 +01:00
Yuki Okushi e9b3985bcf
Suppress some warnings on CI (#143)
* Suppress some warnings on CI

* Remove unused imports
2020-01-23 10:17:13 +09:00

25 lines
615 B
Rust

// <streaming>
use actix_web::{web, Error, HttpResponse};
use futures::StreamExt;
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())
}
// </streaming>
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
use actix_web::{App, HttpServer};
HttpServer::new(|| App::new().route("/", web::post().to(index)))
.bind("127.0.0.1:8088")?
.run()
.await
}