mirror of
https://github.com/actix/actix-website
synced 2025-02-02 12:19:04 +01:00
23 lines
527 B
Rust
23 lines
527 B
Rust
// <chunked>
|
|
use actix_web::{web, HttpRequest, HttpResponse};
|
|
use bytes::Bytes;
|
|
use futures::future::ok;
|
|
use futures::stream::once;
|
|
|
|
async fn index(req: HttpRequest) -> HttpResponse {
|
|
HttpResponse::Ok()
|
|
.chunked()
|
|
.streaming(once(ok::<_, Error>(Bytes::from_static(b"data"))))
|
|
}
|
|
// </chunked>
|
|
|
|
pub fn main() {
|
|
use actix_web::{web, App, HttpServer};
|
|
|
|
HttpServer::new(|| App::new().route("/", web::get().to(index)))
|
|
.bind("127.0.0.1:8088")
|
|
.unwrap()
|
|
.run()
|
|
.unwrap();
|
|
}
|