1
0
mirror of https://github.com/actix/actix-website synced 2025-03-12 03:02:59 +01:00

23 lines
613 B
Rust
Raw Normal View History

2019-06-20 02:04:22 -04:00
pub mod async_stream;
pub mod stream;
// <async-responder>
use actix_web::{web, App, Error, HttpRequest, HttpResponse};
use futures::future::{ok, Future};
2019-06-15 16:37:08 -04:00
2019-06-20 02:04:22 -04:00
fn index(_req: HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> {
Box::new(ok::<_, Error>(
HttpResponse::Ok().content_type("text/html").body("Hello!"),
))
2019-06-15 16:37:08 -04:00
}
2019-06-20 02:04:22 -04:00
fn index2(_req: HttpRequest) -> Box<Future<Item = &'static str, Error = Error>> {
Box::new(ok::<_, Error>("Welcome!"))
2019-06-15 16:37:08 -04:00
}
fn main() {
App::new()
2019-06-20 02:04:22 -04:00
.route("/async", web::to_async(index))
.route("/", web::to_async(index2));
2019-06-15 16:37:08 -04:00
}
2019-06-20 02:04:22 -04:00
// </async-responder>