Compare commits

..

No commits in common. "510bbe738165ce8db077a65ea2574cf85bb6cf22" and "a562c4616c274b929ecff0d35b89f2aee0ab5186" have entirely different histories.

10 changed files with 27 additions and 34 deletions

1
.gitignore vendored
View File

@ -1,3 +1,2 @@
/target /target
Cargo.lock Cargo.lock
/.idea/

View File

@ -3,8 +3,8 @@ use std::ops::Add;
use git2::{Commit, ObjectType, Oid, Reference, Repository, Tree}; use git2::{Commit, ObjectType, Oid, Reference, Repository, Tree};
use crate::gitutils::gitdir::GitDir; use crate::gitdir::GitDir;
use crate::gitutils::gitfile::GitFile; use crate::gitfile::GitFile;
#[derive(Debug)] #[derive(Debug)]
pub enum GitBrowseEntry<'a> { pub enum GitBrowseEntry<'a> {

View File

@ -3,9 +3,9 @@ use std::ops::Add;
use git2::{ObjectType, Oid, Repository, BranchType}; use git2::{ObjectType, Oid, Repository, BranchType};
use crate::git::GitBrowseEntry; use crate::git::GitBrowseEntry;
use crate::gitutils::gitcommit::GitRef; use crate::gitcommit::GitRef;
use crate::gitutils::gitdir::GitDir; use crate::gitdir::GitDir;
use crate::gitutils::gitfile::GitFile; use crate::gitfile::GitFile;
use std::path::{PathBuf, Path}; use std::path::{PathBuf, Path};
use std::str::FromStr; use std::str::FromStr;

View File

@ -1,4 +0,0 @@
pub mod gitdir;
pub mod gitrepo;
pub mod gitcommit;
pub mod gitfile;

View File

@ -7,14 +7,13 @@ use std::process::Stdio;
use actix_files::Files; use actix_files::Files;
use actix_session::{CookieSession, Session}; use actix_session::{CookieSession, Session};
use actix_web::{App, Error, get, HttpMessage, HttpRequest, HttpResponse, HttpServer, post, Responder}; use actix_web::{App, Error, get, HttpMessage, HttpRequest, HttpResponse, HttpServer, post, Responder, web};
use actix_web::client::PayloadError; use actix_web::client::PayloadError;
use actix_web::dev::ServiceRequest; use actix_web::dev::ServiceRequest;
use actix_web::http::{header, StatusCode}; use actix_web::http::{header, StatusCode};
use actix_web::http::header::Header; use actix_web::http::header::Header;
use actix_web::http::header::IntoHeaderValue; use actix_web::http::header::IntoHeaderValue;
use actix_web::middleware::Logger; use actix_web::middleware::Logger;
use actix_web::web as webx;
use actix_web::web::{Buf, Bytes}; use actix_web::web::{Buf, Bytes};
use actix_web_httpauth::extractors::AuthenticationError; use actix_web_httpauth::extractors::AuthenticationError;
use actix_web_httpauth::extractors::basic::{BasicAuth, Config}; use actix_web_httpauth::extractors::basic::{BasicAuth, Config};
@ -28,25 +27,27 @@ use serde::Deserialize;
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader}; use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::process::{Child, ChildStdout, Command}; use tokio::process::{Child, ChildStdout, Command};
use gitutils::gitcommit::GitRef; use gitcommit::GitRef;
use gitutils::gitdir::GitDir; use gitdir::GitDir;
use gitutils::gitfile::GitFile; use gitrepo::GitRepo;
use gitutils::gitrepo::GitRepo;
use crate::git::GitBrowseEntry; use crate::git::GitBrowseEntry;
use crate::gitust::Gitust; use crate::gitust::Gitust;
use crate::ite::SuperIterator; use crate::ite::SuperIterator;
use crate::reader::ToStream; use crate::reader::ToStream;
use crate::writer::Writer; use crate::writer::Writer;
use crate::gitfile::GitFile;
mod git; mod git;
mod ite; mod ite;
mod reader; mod reader;
mod writer; mod writer;
mod gitust; mod gitust;
mod gitdir;
mod gitrepo;
mod gitcommit;
mod gitfile;
mod error; mod error;
mod web;
mod gitutils;
#[derive(Template)] #[derive(Template)]
#[template(path = "hello.html")] #[template(path = "hello.html")]
@ -147,11 +148,9 @@ async fn chunk() -> HttpResponse {
#[get("/git/{owner}/{repo}.git")] #[get("/git/{owner}/{repo}.git")]
async fn git_main( async fn git_main(
webx::Path((ownername, reponame)): webx::Path<(String, String)>, web::Path((ownername, reponame)): web::Path<(String, String)>,
webx::Query(GitWebQ{commit : commitnameopt, path : pathopt, branch : branchopt}) : webx::Query<GitWebQ>, web::Query(GitWebQ{commit : commitnameopt, path : pathopt, branch : branchopt}) : web::Query<GitWebQ>,
gitust : webx::Data<Gitust>, gitust : web::Data<Gitust>
auth : Option<BasicAuth>,
//auth : BasicAuth,
) -> Result<GitMainTemplate<Vec<Entry>, Vec<(String, String)>>, error::Error> { ) -> Result<GitMainTemplate<Vec<Entry>, Vec<(String, String)>>, error::Error> {
let rootname = match pathopt { let rootname = match pathopt {
None => {"".to_string()} None => {"".to_string()}
@ -198,10 +197,10 @@ async fn git_main(
} }
//#[get("/git/{owner}/{repo}.git/{path:.*}")] //#[get("/git/{owner}/{repo}.git/{path:.*}")]
async fn git_proto( async fn git_proto(
mut payload : webx::Payload, mut payload : web::Payload,
webx::Path((owner, reponame, path)): webx::Path<(String, String, String)>, web::Path((owner, reponame, path)): web::Path<(String, String, String)>,
mut req: HttpRequest, mut req: HttpRequest,
gitust : webx::Data<Gitust>, gitust : web::Data<Gitust>,
auth : BasicAuth, auth : BasicAuth,
) -> io::Result<HttpResponse>{ ) -> io::Result<HttpResponse>{
//println!("enter git_proto"); //println!("enter git_proto");
@ -295,7 +294,7 @@ async fn manual_hello() -> impl Responder {
} }
#[get("/{id}/{name}/index.html")] #[get("/{id}/{name}/index.html")]
async fn index(webx::Path((id, name)): webx::Path<(u32, String)>) -> impl Responder { async fn index(web::Path((id, name)): web::Path<(u32, String)>) -> impl Responder {
format!("Hello {}! id:{}", name, id) format!("Hello {}! id:{}", name, id)
} }
@ -352,14 +351,14 @@ async fn main() -> std::io::Result<()> {
// .route("/", web::get().to(hello_auth)) // .route("/", web::get().to(hello_auth))
// ) // )
.service( .service(
webx::resource("/auth") web::resource("/auth")
.wrap(auth) .wrap(auth)
.route(webx::get().to(hello_auth)) .route(web::get().to(hello_auth))
) )
.service( .service(
webx::resource("/git/{user}/{repo}.git/{path:.*}") web::resource("/git/{user}/{repo}.git/{path:.*}")
// .wrap(auth) // .wrap(auth)
.route(webx::route().to(git_proto)) .route(web::route().to(git_proto))
) )
.service( .service(
Files::new("/static", "static") Files::new("/static", "static")
@ -367,7 +366,7 @@ async fn main() -> std::io::Result<()> {
.use_etag(true) .use_etag(true)
// .show_files_listing() // .show_files_listing()
) )
.route("/hey", webx::get().to(manual_hello)) .route("/hey", web::get().to(manual_hello))
}) })
.bind("127.0.0.1:8080")? .bind("127.0.0.1:8080")?
.run() .run()

View File

@ -1 +0,0 @@
mod repo;

View File