mirror of
https://github.com/actix/actix-website
synced 2025-02-23 20:53:01 +01:00
18 lines
417 B
Rust
18 lines
417 B
Rust
|
// <main>
|
||
|
use actix_web::{App, Body, HttpRequest, HttpResponse};
|
||
|
use bytes::Bytes;
|
||
|
use futures::stream::once;
|
||
|
|
||
|
fn index(_req: &HttpRequest) -> HttpResponse {
|
||
|
let body = once(Ok(Bytes::from_static(b"test")));
|
||
|
|
||
|
HttpResponse::Ok()
|
||
|
.content_type("application/json")
|
||
|
.body(Body::Streaming(Box::new(body)))
|
||
|
}
|
||
|
|
||
|
pub fn main() {
|
||
|
App::new().resource("/async", |r| r.f(index)).finish();
|
||
|
}
|
||
|
// </main>
|