mirror of
https://github.com/actix/actix-website
synced 2025-02-02 12:19:04 +01:00
22 lines
518 B
Rust
22 lines
518 B
Rust
use std::io;
|
|
|
|
// <chunked>
|
|
use actix_web::{get, web, App, Error, HttpRequest, HttpResponse, HttpServer};
|
|
use futures::future::ok;
|
|
use futures::stream::once;
|
|
|
|
#[get("/")]
|
|
async fn index(_req: HttpRequest) -> HttpResponse {
|
|
HttpResponse::Ok().streaming(once(ok::<_, Error>(web::Bytes::from_static(b"data"))))
|
|
}
|
|
// </chunked>
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> io::Result<()> {
|
|
HttpServer::new(|| App::new().service(index))
|
|
.bind(("127.0.0.1", 8080))
|
|
.unwrap()
|
|
.run()
|
|
.await
|
|
}
|