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

25 lines
567 B
Rust
Raw Normal View History

2019-06-15 16:37:08 -04:00
fn is_error() -> bool {
true
}
// <main>
use actix_web::{error, App, Error, HttpRequest, HttpResponse};
use futures::future::{result, Future};
fn index(
_req: &HttpRequest,
) -> Result<Box<Future<Item = HttpResponse, Error = Error>>, Error> {
if is_error() {
Err(error::ErrorBadRequest("bad request"))
} else {
Ok(Box::new(result(Ok(HttpResponse::Ok()
.content_type("text/html")
.body(format!("Hello!"))))))
}
}
// </main>
pub fn main() {
App::new().resource("/", |r| r.route().f(index)).finish();
}