From cd729effb9ad4062f83da8aa423fbd7bd31576dc Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 8 May 2021 15:12:25 +0530 Subject: [PATCH] updated docs route --- src/docs.rs | 14 ++++++++++---- templates/panel/header/sidebar/index.html | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/docs.rs b/src/docs.rs index f0b6a968..e28c255c 100644 --- a/src/docs.rs +++ b/src/docs.rs @@ -35,7 +35,7 @@ pub mod routes { impl Docs { pub const fn new() -> Self { Docs { - home: "/docs", + home: "/docs/", spec: "/docs/openapi.json", assets: "/docs/{_:.*}", } @@ -45,8 +45,7 @@ pub mod routes { pub fn services(cfg: &mut web::ServiceConfig) { use crate::define_resource; - - define_resource!(cfg, DOCS.home, Methods::Get, index); + define_resource!(cfg, &DOCS.home[0..DOCS.home.len() - 1], Methods::Get, index); define_resource!(cfg, DOCS.spec, Methods::Get, spec); define_resource!(cfg, DOCS.assets, Methods::Get, dist); } @@ -100,7 +99,14 @@ mod tests { async fn docs_works() { const FILE: &str = "favicon-32x32.png"; - let mut app = test::init_service(App::new().configure(services)).await; + let mut app = test::init_service( + App::new() + .wrap(actix_middleware::NormalizePath::new( + actix_middleware::normalize::TrailingSlash::Trim, + )) + .configure(services), + ) + .await; let resp = test::call_service( &mut app, diff --git a/templates/panel/header/sidebar/index.html b/templates/panel/header/sidebar/index.html index 0996ba8d..f1d019ad 100644 --- a/templates/panel/header/sidebar/index.html +++ b/templates/panel/header/sidebar/index.html @@ -65,7 +65,7 @@
  • - + " alt="" />
    API Docs