Compare commits
3 Commits
dee090ad58
...
97ebae11f8
Author | SHA1 | Date |
---|---|---|
hubert | 97ebae11f8 | |
Hubert | f4f4c5a0a2 | |
Hubert | ffeba7e69c |
|
@ -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"
|
||||||
|
|
32
src/main.rs
32
src/main.rs
|
@ -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;
|
||||||
|
@ -98,6 +115,10 @@ async fn git_main(web::Path((owner, reponame, commitname, rootname)): web::Path<
|
||||||
let user = User { name : "Hubert".to_string()};
|
let user = User { name : "Hubert".to_string()};
|
||||||
GitMainTemplate { repo, browse : browse, root : path, user_opt : Some(user)}
|
GitMainTemplate { repo, browse : browse, root : path, user_opt : Some(user)}
|
||||||
}
|
}
|
||||||
|
//#[get("/git/{owner}/{repo}.git/{path:.*}")]
|
||||||
|
async fn git_proto(web::Path((owner, reponame)): web::Path<(String, String)>, req: HttpRequest) -> impl Responder{
|
||||||
|
"not yet implemented"
|
||||||
|
}
|
||||||
|
|
||||||
#[post("/echo")]
|
#[post("/echo")]
|
||||||
async fn echo(req_body: String) -> impl Responder {
|
async fn echo(req_body: String) -> impl Responder {
|
||||||
|
@ -155,6 +176,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
.service(askama)
|
.service(askama)
|
||||||
.service(git_main)
|
.service(git_main)
|
||||||
.service(hello_session)
|
.service(hello_session)
|
||||||
|
//.service(git_proto)
|
||||||
// .service(
|
// .service(
|
||||||
// web::scope("/auth")
|
// web::scope("/auth")
|
||||||
// .wrap(auth)
|
// .wrap(auth)
|
||||||
|
@ -165,6 +187,10 @@ async fn main() -> std::io::Result<()> {
|
||||||
.wrap(auth)
|
.wrap(auth)
|
||||||
.route(web::get().to(hello_auth))
|
.route(web::get().to(hello_auth))
|
||||||
)
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/git/{user}/{repo}.git/{path:.*}")
|
||||||
|
.route(web::route().to(git_proto))
|
||||||
|
)
|
||||||
.service(
|
.service(
|
||||||
Files::new("/static", "static")
|
Files::new("/static", "static")
|
||||||
.use_last_modified(true)
|
.use_last_modified(true)
|
||||||
|
@ -176,4 +202,4 @@ async fn main() -> std::io::Result<()> {
|
||||||
.bind("127.0.0.1:8080")?
|
.bind("127.0.0.1:8080")?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue