feat: Use a context struct to store global template context

This commit is contained in:
Ginger
2026-03-18 10:26:43 -04:00
parent f9d1f71343
commit 51b450c05c
5 changed files with 82 additions and 45 deletions
+9 -4
View File
@@ -9,6 +9,8 @@ use conduwuit_service::state;
use tower_http::set_header::SetResponseHeaderLayer;
use tower_sec_fetch::SecFetchLayer;
use crate::pages::TemplateContext;
mod pages;
type State = state::State;
@@ -40,8 +42,9 @@ impl IntoResponse for WebError {
struct Error {
error: WebError,
status: StatusCode,
allow_indexing: bool,
context: TemplateContext,
}
let status = match &self {
| Self::ValidationError(_)
| Self::BadRequest(_)
@@ -54,9 +57,11 @@ impl IntoResponse for WebError {
let template = Error {
error: self,
status,
// Statically set false to prevent error pages from being indexed and to prevent
// further errors if services.config is having issues.
allow_indexing: false,
context: TemplateContext {
// Statically set false to prevent error pages from being indexed and to prevent
// further errors if services.config is having issues.
allow_indexing: false,
},
};
if let Ok(body) = template.render() {