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

24 lines
531 B
Rust
Raw Normal View History

2019-06-20 02:04:22 -04:00
// <stream>
2019-06-28 13:31:30 -04:00
use actix_web::{Error, HttpResponse};
2019-06-15 16:37:08 -04:00
use bytes::Bytes;
use futures::stream::once;
2019-06-28 13:31:30 -04:00
fn index() -> HttpResponse {
2019-06-20 02:04:22 -04:00
let body = once::<Bytes, Error>(Ok(Bytes::from_static(b"test")));
2019-06-15 16:37:08 -04:00
HttpResponse::Ok()
.content_type("application/json")
2019-06-20 02:04:22 -04:00
.streaming(Box::new(body))
2019-06-15 16:37:08 -04:00
}
pub fn main() {
2019-06-28 13:31:30 -04:00
use actix_web::{web, App, HttpServer};
2019-06-20 02:04:22 -04:00
HttpServer::new(|| App::new().route("/async", web::to_async(index)))
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
2019-06-15 16:37:08 -04:00
}
2019-06-20 02:04:22 -04:00
// </stream>