aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs31
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
}