mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Use a context struct to store global template context
This commit is contained in:
+9
-4
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user