Generate backlinks
All checks were successful
CI / Check typos (push) Successful in 8s
CI / Check links (push) Successful in 33s
CI / Clippy (push) Successful in 1m1s
CI / Build and test (push) Successful in 1m8s
CI / Build container (push) Successful in 45s
CI / Deploy on waypoint (push) Successful in 45s
All checks were successful
CI / Check typos (push) Successful in 8s
CI / Check links (push) Successful in 33s
CI / Clippy (push) Successful in 1m1s
CI / Build and test (push) Successful in 1m8s
CI / Build container (push) Successful in 45s
CI / Deploy on waypoint (push) Successful in 45s
This commit is contained in:
@@ -93,16 +93,18 @@ impl PageServer {
|
||||
) -> Option<(String, Option<DateTime<Utc>>)> {
|
||||
let now = Utc::now();
|
||||
let start = Instant::now();
|
||||
trace!(message = "Rendering page", route, reason);
|
||||
|
||||
let page = match self.pages.lock().get(route) {
|
||||
Some(x) => x.clone(),
|
||||
None => {
|
||||
warn!(message = "Not rerendering, no such route", route, reason);
|
||||
return None;
|
||||
}
|
||||
None => return None,
|
||||
};
|
||||
|
||||
trace!(
|
||||
message = "Rendering page",
|
||||
route,
|
||||
reason,
|
||||
lock_time_ms = start.elapsed().as_millis()
|
||||
);
|
||||
|
||||
let html = (self.render_page)(&page, &req_ctx).await.0;
|
||||
|
||||
let mut expires = None;
|
||||
@@ -130,6 +132,14 @@ impl PageServer {
|
||||
.and_then(|x| x.to_str().ok())
|
||||
.unwrap_or("");
|
||||
|
||||
trace!(
|
||||
message = "Serving route",
|
||||
route,
|
||||
addr = ?addr.addr,
|
||||
user_agent = ua,
|
||||
device_type = ?client_info.device_type
|
||||
);
|
||||
|
||||
// Normalize url with redirect
|
||||
if route.ends_with('/') || route.contains("//") || route.starts_with('/') {
|
||||
let mut new_route = route.clone();
|
||||
@@ -139,7 +149,7 @@ impl PageServer {
|
||||
let new_route = new_route.trim_matches('/');
|
||||
|
||||
trace!(
|
||||
message = "Redirecting route",
|
||||
message = "Redirecting",
|
||||
route,
|
||||
new_route,
|
||||
addr = ?addr.addr,
|
||||
@@ -162,15 +172,10 @@ impl PageServer {
|
||||
return (StatusCode::PERMANENT_REDIRECT, headers).into_response();
|
||||
}
|
||||
|
||||
trace!(
|
||||
message = "Serving route",
|
||||
route,
|
||||
addr = ?addr.addr,
|
||||
user_agent = ua,
|
||||
device_type = ?client_info.device_type
|
||||
);
|
||||
|
||||
let req_ctx = RequestContext { client_info };
|
||||
let req_ctx = RequestContext {
|
||||
client_info,
|
||||
route: format!("/{route}"),
|
||||
};
|
||||
|
||||
let cache_key = (route.clone(), req_ctx.clone());
|
||||
let now = Utc::now();
|
||||
@@ -186,7 +191,17 @@ impl PageServer {
|
||||
if html_expires.is_none() {
|
||||
html_expires = match state.render_page("request", &route, req_ctx).await {
|
||||
Some(x) => Some(x.clone()),
|
||||
None => return (StatusCode::NOT_FOUND, "page doesn't exist").into_response(),
|
||||
None => {
|
||||
trace!(
|
||||
message = "Not found",
|
||||
route,
|
||||
addr = ?addr.addr,
|
||||
user_agent = ua,
|
||||
device_type = ?client_info.device_type
|
||||
);
|
||||
|
||||
return (StatusCode::NOT_FOUND, "page doesn't exist").into_response();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user