updated docs route

This commit is contained in:
realaravinth 2021-05-08 15:12:25 +05:30
parent 9809cb7bea
commit cd729effb9
No known key found for this signature in database
GPG Key ID: AD9F0F08E855ED88
2 changed files with 11 additions and 5 deletions

View File

@ -35,7 +35,7 @@ pub mod routes {
impl Docs { impl Docs {
pub const fn new() -> Self { pub const fn new() -> Self {
Docs { Docs {
home: "/docs", home: "/docs/",
spec: "/docs/openapi.json", spec: "/docs/openapi.json",
assets: "/docs/{_:.*}", assets: "/docs/{_:.*}",
} }
@ -45,8 +45,7 @@ pub mod routes {
pub fn services(cfg: &mut web::ServiceConfig) { pub fn services(cfg: &mut web::ServiceConfig) {
use crate::define_resource; use crate::define_resource;
define_resource!(cfg, &DOCS.home[0..DOCS.home.len() - 1], Methods::Get, index);
define_resource!(cfg, DOCS.home, Methods::Get, index);
define_resource!(cfg, DOCS.spec, Methods::Get, spec); define_resource!(cfg, DOCS.spec, Methods::Get, spec);
define_resource!(cfg, DOCS.assets, Methods::Get, dist); define_resource!(cfg, DOCS.assets, Methods::Get, dist);
} }
@ -100,7 +99,14 @@ mod tests {
async fn docs_works() { async fn docs_works() {
const FILE: &str = "favicon-32x32.png"; 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( let resp = test::call_service(
&mut app, &mut app,

View File

@ -65,7 +65,7 @@
</a> </a>
</li> </li>
<li class="secondary-menu__item"> <li class="secondary-menu__item">
<a class="secondary-menu__item-link" href="<.= crate::DOCS.home .>/"> <a class="secondary-menu__item-link" href="<.= crate::DOCS.home .>">
<img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/file-text.svg").unwrap() .>" alt="" /> <img class="secondary-menu__icon" src="<.= crate::FILES.get("./static-assets/img/svg/file-text.svg").unwrap() .>" alt="" />
<div class="secondary-menu__item-name"> <div class="secondary-menu__item-name">
API Docs API Docs