Skip to content

Commit dd812ae

Browse files
committed
tries
1 parent 09a19c2 commit dd812ae

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/web/routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub(super) fn build_axum_routes() -> AxumRouter {
129129
"/favicon.ico",
130130
get_static(|| async { Redirect::permanent("/-/static/favicon.ico") }),
131131
)
132-
.nest("/-/static/", build_static_router())
132+
.nest("/-/static", build_static_router())
133133
.route(
134134
"/opensearch.xml",
135135
get_static(|| async { Redirect::permanent("/-/static/opensearch.xml") }),

src/web/statics.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use super::{cache::CachePolicy, metrics::request_recorder, routes::get_static};
22
use axum::{
33
extract::{Extension, Request},
44
http::header::CONTENT_TYPE,
5+
http::{StatusCode, Uri},
56
middleware,
67
middleware::Next,
78
response::{IntoResponse, Response},
@@ -67,13 +68,18 @@ pub(crate) fn build_static_router() -> AxumRouter {
6768
"/rustdoc-2021-12-05.css",
6869
get_static(|| async { build_static_css_response(RUSTDOC_2021_12_05_CSS) }),
6970
)
70-
.fallback_service(
71-
get_service(ServeDir::new("static").fallback(ServeDir::new("vendor")))
72-
.layer(middleware::from_fn(set_needed_static_headers))
73-
.layer(middleware::from_fn(|request, next| async {
74-
request_recorder(request, next, Some("static resource")).await
75-
})),
76-
)
71+
.fallback(fallback)
72+
// .fallback_service(
73+
// get_service(ServeDir::new("static").fallback(ServeDir::new("vendor")))
74+
// .layer(middleware::from_fn(set_needed_static_headers))
75+
// .layer(middleware::from_fn(|request, next| async {
76+
// request_recorder(request, next, Some("static resource")).await
77+
// })),
78+
// )
79+
}
80+
async fn fallback(uri: Uri) -> (StatusCode, String) {
81+
dbg!(&uri);
82+
(StatusCode::NOT_FOUND, format!("No route for {uri}"))
7783
}
7884

7985
#[cfg(test)]
@@ -165,7 +171,12 @@ mod tests {
165171
let web = env.web_app().await;
166172

167173
let resp = web.get(path).await?;
168-
assert!(resp.status().is_success(), "{}", resp.status());
174+
if !resp.status().is_success() {
175+
let status = resp.status();
176+
dbg!(&resp.text().await);
177+
assert!(status.is_success(), "{}", status);
178+
panic!("as");
179+
}
169180
resp.assert_cache_control(CachePolicy::ForeverInCdnAndBrowser, &env.config());
170181
assert_eq!(
171182
resp.headers().get("Content-Type"),

0 commit comments

Comments
 (0)