use axum::http::StatusCode;
use axum::response::Html;
use tracing::error;
use crate::AppState;
pub mod auth;
pub mod notes;
pub use auth::{
handle_create_invite, handle_login, handle_logout, handle_register, show_invites, show_login,
show_profile, show_register,
};
pub use notes::{create_note, list_notes, note_status, show_note};
/// Render a named template with the given context, mapping failures to a 500
/// plus a log line. Templates are data rather than code, so a typo in one only
/// surfaces here at render time — hence the logging rather than a bare `?`.
pub(crate) fn render(
state: &AppState,
name: &str,
ctx: minijinja::Value,
) -> Result<Html<String>, StatusCode> {
let template = state.env.get_template(name).map_err(|e| {
error!(template = name, error = %e, "load template failed");
StatusCode::INTERNAL_SERVER_ERROR
})?;
let body = template.render(ctx).map_err(|e| {
error!(template = name, error = %e, "render template failed");
StatusCode::INTERNAL_SERVER_ERROR
})?;
Ok(Html(body))
}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.1 KiB · text
History
7f67051