generalise git_main

This commit is contained in:
hubert 2021-07-22 13:36:48 +02:00
parent 90ea298a61
commit 22836e1f3a
2 changed files with 4 additions and 2 deletions

View File

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

View File

@ -1,3 +1,4 @@
use crate::auth::AuthValidator;
use std::path::Path;
use actix_web::web;
@ -56,11 +57,12 @@ pub struct GitWebQ {
}
//#[get("/git/{owner}/{repo}.git")]
pub async fn git_main(
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()))?;