2022-02-26 03:56:24 +00:00
|
|
|
use std::io;
|
|
|
|
|
2020-01-02 18:33:33 +06:00
|
|
|
// <chunked>
|
2020-11-27 01:10:05 +00:00
|
|
|
use actix_web::{get, web, App, Error, HttpRequest, HttpResponse, HttpServer};
|
2020-01-02 18:33:33 +06:00
|
|
|
use futures::future::ok;
|
|
|
|
use futures::stream::once;
|
2019-06-17 15:15:33 -04:00
|
|
|
|
2020-09-12 16:21:54 +01:00
|
|
|
#[get("/")]
|
|
|
|
async fn index(_req: HttpRequest) -> HttpResponse {
|
2020-11-27 01:10:05 +00:00
|
|
|
HttpResponse::Ok().streaming(once(ok::<_, Error>(web::Bytes::from_static(b"data"))))
|
2020-01-02 18:33:33 +06:00
|
|
|
}
|
|
|
|
// </chunked>
|
2019-06-26 01:58:47 -04:00
|
|
|
|
2020-09-12 16:21:54 +01:00
|
|
|
#[actix_web::main]
|
2022-02-26 03:56:24 +00:00
|
|
|
async fn main() -> io::Result<()> {
|
2020-09-12 16:21:54 +01:00
|
|
|
HttpServer::new(|| App::new().service(index))
|
2022-02-26 03:56:24 +00:00
|
|
|
.bind(("127.0.0.1", 8080))
|
2020-01-02 18:33:33 +06:00
|
|
|
.unwrap()
|
2022-02-26 03:56:24 +00:00
|
|
|
.run()
|
|
|
|
.await
|
2020-01-02 18:33:33 +06:00
|
|
|
}
|