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

34 lines
722 B
Rust
Raw Normal View History

pub mod helpers;
pub mod logging;
pub mod override_error;
pub mod recommend_one;
2019-06-24 21:18:30 -04:00
pub mod recommend_two;
2019-06-17 13:46:21 -04:00
// <response-error>
2019-06-28 14:22:51 -04:00
use actix_web::{error, Result};
2019-06-17 13:46:21 -04:00
use failure::Fail;
#[derive(Fail, Debug)]
#[fail(display = "my error")]
struct MyError {
2019-06-17 13:46:21 -04:00
name: &'static str,
}
// Use default implementation for `error_response()` method
impl error::ResponseError for MyError {}
async fn index() -> Result<&'static str, MyError> {
2019-06-17 13:46:21 -04:00
Err(MyError { name: "test" })
}
// </response-error>
2019-06-24 21:18:30 -04:00
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
use actix_web::{web, App, HttpServer};
2019-06-24 21:18:30 -04:00
HttpServer::new(|| App::new().route("/", web::get().to(index)))
.bind("127.0.0.1:8088")?
.run()
.await
}