2019-06-19 00:20:50 -04:00
|
|
|
pub mod helpers;
|
|
|
|
pub mod override_error;
|
|
|
|
pub mod recommend_one;
|
|
|
|
use actix_web::{web, App};
|
2019-06-17 13:46:21 -04:00
|
|
|
// <response-error>
|
|
|
|
use actix_web::{error, HttpRequest};
|
|
|
|
use failure::Fail;
|
|
|
|
|
|
|
|
#[derive(Fail, Debug)]
|
|
|
|
#[fail(display = "my error")]
|
2019-06-19 00:20:50 -04:00
|
|
|
pub 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 {}
|
|
|
|
|
2019-06-19 00:20:50 -04:00
|
|
|
fn index(_req: HttpRequest) -> Result<&'static str, MyError> {
|
2019-06-17 13:46:21 -04:00
|
|
|
Err(MyError { name: "test" })
|
|
|
|
}
|
|
|
|
// </response-error>
|
2019-06-19 00:20:50 -04:00
|
|
|
pub fn main() {
|
|
|
|
App::new().route("/", web::get().to(index));
|
|
|
|
}
|