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

26 lines
540 B
Rust
Raw Normal View History

use actix_web::{web, App};
2019-06-17 13:46:21 -04:00
// <helpers>
2019-06-28 13:31:30 -04:00
use actix_web::{error, Result};
2019-06-17 13:46:21 -04:00
#[derive(Debug)]
struct MyError {
name: &'static str,
}
2019-06-28 13:31:30 -04:00
pub fn index() -> Result<&'static str> {
2019-06-24 21:18:30 -04:00
let result: Result<&'static str, MyError> = Err(MyError { name: "test error" });
2019-06-17 13:46:21 -04:00
Ok(result.map_err(|e| error::ErrorBadRequest(e.name))?)
}
// </helpers>
2019-06-24 21:18:30 -04:00
pub fn main() {
2019-06-24 21:18:30 -04:00
use actix_web::HttpServer;
HttpServer::new(|| App::new().route("/", web::get().to(index)))
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
}