1
0
mirror of https://github.com/actix/actix-website synced 2025-02-02 12:19:04 +01:00

23 lines
527 B
Rust
Raw Normal View History

2020-01-02 18:33:33 +06:00
// <chunked>
use actix_web::{web, HttpRequest, HttpResponse};
use bytes::Bytes;
use futures::future::ok;
use futures::stream::once;
2019-06-17 15:15:33 -04:00
2020-01-02 18:33:33 +06:00
async fn index(req: HttpRequest) -> HttpResponse {
HttpResponse::Ok()
.chunked()
.streaming(once(ok::<_, Error>(Bytes::from_static(b"data"))))
}
// </chunked>
2019-06-26 01:58:47 -04:00
2020-01-02 18:33:33 +06:00
pub fn main() {
use actix_web::{web, App, HttpServer};
2019-06-26 01:58:47 -04:00
2020-01-02 18:33:33 +06:00
HttpServer::new(|| App::new().route("/", web::get().to(index)))
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
}