index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff

Diffstat (limited to 'src/main.rs')

-rw-r--r-- src/main.rs 46
 1 file changed, 46 insertions(+)

diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..b7c227d 100644
--- /dev/null
+++ b/src/main.rs
@@ -1,0 +1,46 @@
use crate::prelude::*;
use actix_web::{App as ActixApp, HttpServer, web};
use clap::Parser;
use std::io::Error;

use crate::cli::Args;

pub mod app;
pub mod cli;
pub mod error;
pub mod git;
pub mod markdown;
pub mod prelude;
pub mod routes;
pub mod time;

#[actix_web::main]
async fn main() -> Result<(), Error> {
    let args = Args::parse();
    let app = web::Data::new(App::new(args.repos_dir.to_string()).await);

    HttpServer::new(move || {
        ActixApp::new()
            .app_data(app.clone())
            .service(routes::r#static::files)
            .service(routes::git::git_info_refs)
            .service(routes::git::git_upload_pack)
            .service(routes::git::git_receive_pack)
            .service(routes::repository::diff::patch)
            .service(routes::repository::snapshot::download)
            .service(routes::page)
            .service(routes::about::page)
            .service(routes::repository::about::page)
            .service(routes::repository::summary::page)
            .service(routes::repository::refs::page)
            .service(routes::repository::tag::page)
            .service(routes::repository::log::page)
            .service(routes::repository::tree::page)
            .service(routes::repository::tree::raw)
            .service(routes::repository::commit::page)
            .service(routes::repository::diff::page)
    })
    .bind((args.url, args.port))?
    .run()
    .await
}