1
0
mirror of https://github.com/actix/actix-website synced 2025-02-13 08:32:20 +01:00

21 lines
497 B
Rust
Raw Normal View History

2020-01-02 18:33:33 +06:00
// <chunked>
2020-01-02 18:36:32 +06:00
use actix_web::{web, HttpRequest, HttpResponse, Error};
2020-01-02 18:33:33 +06:00
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()
.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()
2020-01-02 18:36:32 +06:00
.run();
2020-01-02 18:33:33 +06:00
}