This commit is contained in:
Hubert 2021-07-07 06:49:53 +02:00
parent dee090ad58
commit ffeba7e69c
2 changed files with 20 additions and 2 deletions

View File

@ -14,3 +14,4 @@ actix-files = "0.5.0"
askama = "0.10.5" askama = "0.10.5"
askama_actix = "0.11.1" askama_actix = "0.11.1"
env_logger = "0.8.4" env_logger = "0.8.4"
serde = "1.0.126"

View File

@ -17,6 +17,7 @@ use env_logger::Env;
use crate::ite::SuperIterator; use crate::ite::SuperIterator;
use std::ops::Add; use std::ops::Add;
use std::path::{PathBuf, Path}; use std::path::{PathBuf, Path};
use serde::Deserialize;
#[derive(Template)] #[derive(Template)]
#[template(path = "hello.html")] #[template(path = "hello.html")]
@ -83,8 +84,24 @@ async fn hello_auth(req : HttpRequest) -> impl Responder {
} }
} }
#[get("/git/{owner}/{repo}/{commit}/{path:.*}")]
async fn git_main(web::Path((owner, reponame, commitname, rootname)): web::Path<(String, String, String, String)>) -> impl Responder { #[derive(Deserialize)]
struct GitWebQ {
commit: Option<String>,
path: Option<String>,
}
#[get("/git/{owner}/{repo}.git")]
async fn git_main(web::Path((owner, reponame)): web::Path<(String, String)>, web::Query(GitWebQ{commit : commitnameopt, path : pathopt}) : web::Query<GitWebQ>) -> impl Responder {
let commitname = match commitnameopt {
None => {"master".to_string()}
Some(s) => {s}
};
let rootname = match pathopt {
None => {"/".to_string()}
Some(s) => {s}
};
let repo = GitRepo::new(); let repo = GitRepo::new();
let path : Vec<(String, String)> = rootname.split("/").map_accum("/git/".to_string() + &owner + "/" + &reponame + "/" + &commitname, |str_ref, b| { let path : Vec<(String, String)> = rootname.split("/").map_accum("/git/".to_string() + &owner + "/" + &reponame + "/" + &commitname, |str_ref, b| {
let href = b + "/" + str_ref; let href = b + "/" + str_ref;