From 2a73370c9f7ce543a900be7ade2cfe0230dccefb Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 19 Sep 2020 14:22:56 +0200 Subject: [PATCH] Use normalize path middleware --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index b90a9ce..40c521a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,8 @@ use crate::{ }; use actix_web::{ http::header::{CacheControl, CacheDirective, Expires, LOCATION}, - middleware, web, App, HttpResponse, HttpServer, Responder, + middleware::{self, normalize::TrailingSlash}, + web, App, HttpResponse, HttpServer, Responder, }; use badge::{Badge, BadgeOptions}; use git2::{BranchType, Repository}; @@ -124,7 +125,7 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64 arg.push("--".to_string()); arg.push(".".to_string()); let output = Command::new("git") - .args(&dbg!(arg)) + .args(&arg) .current_dir(&repo_dir) .output()? .stdout; @@ -186,8 +187,8 @@ where data.1.to_lowercase() ); info!("Deleting cache and repository for {}", repo); - let cache_dir = dbg!(format!("{}/{}.json", &state.cache, repo)); - let repo_dir = dbg!(format!("{}/{}", &state.repos, repo)); + let cache_dir = format!("{}/{}.json", &state.cache, repo); + let repo_dir = format!("{}/{}", &state.repos, repo); std::fs::remove_file(&cache_dir).or_else(|e| { if e.kind() == io::ErrorKind::NotFound { Ok(()) @@ -412,7 +413,7 @@ async fn start_server() -> std::io::Result<()> { App::new() .data(state.clone()) .wrap(middleware::Logger::default()) - // .wrap(middleware::NormalizePath::default()) + .wrap(middleware::NormalizePath::new(TrailingSlash::Trim)) .service(index) .service(web::resource("/tacit-css.min.css").route(web::get().to(css))) // TODO