Compare commits

..

3 Commits

Author SHA1 Message Date
hubert 9832f30360 add commented line as place holder 2021-07-22 13:52:49 +02:00
hubert 22836e1f3a generalise git_main 2021-07-22 13:36:48 +02:00
hubert 90ea298a61 prepare generalisation git_main 2021-07-22 13:33:49 +02:00
2 changed files with 9 additions and 3 deletions

View File

@ -172,7 +172,10 @@ async fn main() -> std::io::Result<()> {
.service(hello_test)
.service(index)
.service(askama)
.service(repo::git_main)
.service(
webx::resource("/git/{owner}/{repo}.git")
.route(webx::get().to(repo::git_main::<auth::TestValidator>))
)
.service(hello_session)
.service(chunk)
//.service(git_proto)

View File

@ -1,3 +1,4 @@
use crate::auth::AuthValidator;
use std::path::Path;
use actix_web::web;
@ -55,15 +56,17 @@ pub struct GitWebQ {
branch: Option<String>,
}
#[get("/git/{owner}/{repo}.git")]
pub async fn git_main(
//#[get("/git/{owner}/{repo}.git")]
pub async fn git_main<T : AuthValidator>(
web::Path((ownername, reponame)): web::Path<(String, String)>,
web::Query(GitWebQ{commit : commitnameopt, path : pathopt, branch : branchopt}) : web::Query<GitWebQ>,
gitust : web::Data<Gitust>,
auth : Option<basic::BasicAuth>,
validator : web::Data<T>,
//auth : BasicAuth,
) -> Result<GitMainTemplate<Vec<Entry>, Vec<(String, String)>>, error::Error> {
// let authtorization = auth.ok_or(error::Error::Unauthorized("safe repo".to_string()))?;
//let authorization = auth.and_then(|cred| validator.check_basic(&cred)).ok_or(error::Error::Unauthorized("safe repo".to_string()))?;
let rootname = match pathopt {
None => {"".to_string()}
Some(s) => {