dashboard: error_response takes &str

This commit is contained in:
müde 2026-05-15 00:06:51 +02:00
parent c82d41728c
commit 46ff9c7aee
2 changed files with 11 additions and 4 deletions

7
Cargo.lock generated
View file

@ -325,6 +325,7 @@ dependencies = [
"rusqlite",
"serde",
"serde_json",
"similar",
"tokio",
"tracing",
"tracing-subscriber",
@ -681,6 +682,12 @@ dependencies = [
"libc",
]
[[package]]
name = "similar"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
[[package]]
name = "slab"
version = "0.4.12"

View file

@ -67,23 +67,23 @@ async fn post_approve(
) -> Response {
match actions::approve(&state.coord, id).await {
Ok(()) => Redirect::to("/").into_response(),
Err(e) => error_response(format!("approve {id} failed: {e:#}")),
Err(e) => error_response(&format!("approve {id} failed: {e:#}")),
}
}
async fn post_deny(State(state): State<AppState>, AxumPath(id): AxumPath<i64>) -> Response {
match actions::deny(&state.coord, id) {
Ok(()) => Redirect::to("/").into_response(),
Err(e) => error_response(format!("deny {id} failed: {e:#}")),
Err(e) => error_response(&format!("deny {id} failed: {e:#}")),
}
}
fn error_response(message: String) -> Response {
fn error_response(message: &str) -> Response {
(
StatusCode::INTERNAL_SERVER_ERROR,
Html(format!(
"<!doctype html>\n<html>\n<head>{STYLE}</head>\n<body>{BANNER}\n<h2>◆ ERR0R ◆</h2>\n<pre class=\"diff\">{message}</pre>\n<p><a href=\"/\">← back</a></p>\n</body></html>",
message = html_escape(&message),
message = html_escape(message),
)),
)
.into_response()