| 1 | use crate::prelude::*; |
| 2 | use actix_web::{App as ActixApp, HttpServer, web}; |
| 3 | use clap::Parser; |
| 4 | use std::io::Error; |
| 5 | |
| 6 | use crate::cli::Args; |
| 7 | |
| 8 | pub mod app; |
| 9 | pub mod cli; |
| 10 | pub mod error; |
| 11 | pub mod git; |
| 12 | pub mod markdown; |
| 13 | pub mod prelude; |
| 14 | pub mod routes; |
| 15 | pub mod syntax_highlight; |
| 16 | pub mod time; |
| 17 | |
| 18 | #[actix_web::main] |
| 19 | async fn main() -> Result<(), Error> { |
| 20 | let args = Args::parse(); |
| 21 | let app = web::Data::new(App::new(args.repos_dir.to_string()).await); |
| 22 | |
| 23 | HttpServer::new(move || { |
| 24 | ActixApp::new() |
| 25 | .app_data(app.clone()) |
| 26 | .service(routes::r#static::files) |
| 27 | .service(routes::git::git_info_refs) |
| 28 | .service(routes::git::git_upload_pack) |
| 29 | .service(routes::repository::diff::patch) |
| 30 | .service(routes::repository::snapshot::download) |
| 31 | .service(routes::page) |
| 32 | .service(routes::about::page) |
| 33 | .service(routes::repository::about::page) |
| 34 | .service(routes::repository::summary::page) |
| 35 | .service(routes::repository::refs::page) |
| 36 | .service(routes::repository::tag::page) |
| 37 | .service(routes::repository::log::page) |
| 38 | .service(routes::repository::tree::page) |
| 39 | .service(routes::repository::tree::raw) |
| 40 | .service(routes::repository::commit::page) |
| 41 | .service(routes::repository::diff::page) |
| 42 | }) |
| 43 | .bind((args.url, args.port))? |
| 44 | .run() |
| 45 | .await |
| 46 | } |
