diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-01-23 22:29:46 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-01-23 22:29:46 +0100 |
commit | 5db4c57b0360f6d6f9d6553d9b438a804ad441ae (patch) | |
tree | 8c9b91df4e6bafca0fc058613cd8eddd788f0a95 /src/main.rs | |
parent | 5e16c6400307d93e90ced300efb3ee4eb76c0524 (diff) |
Updating to actix 2.0.0 and adding 404 handlerfn-verify-9324832
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs index c0b0f61..d6a4b36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,23 @@ mod pages; mod repo; -fn main() -> std::io::Result<()> { - // use actix_files as fs; - // use actix_web::{web, App, HttpServer}; +use actix_files as fs; +use actix_web::{web, App, HttpServer}; +use std::io; - // start http server - // HttpServer::new(move || { - // App::new() - // .service(fs::Files::new("/static", "static")) - // .service(web::resource("/{repo}").route(web::get().to(pages::repo::render))) - // }) - // .bind("127.0.0.1:8080")? - // .run()?; - - Ok(()) +#[actix_rt::main] +async fn main() -> io::Result<()> { + HttpServer::new(|| { + App::new() + .service(fs::Files::new("/static", "static")) + .service(web::resource("/{repo}").route(web::get().to(pages::repo::about::render))) + // default + .default_service( + // 404 for GET request + web::resource("").route(web::get().to(pages::p404::render)), + ) + }) + .bind("127.0.0.1:8080")? + .run() + .await } |