inline problem_details builder at call sites; drop the one-caller wrapper
This commit is contained in:
parent
cdf1bfe7db
commit
2b0c51badf
8 changed files with 79 additions and 78 deletions
|
|
@ -13,7 +13,9 @@ use axum::{
|
|||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::{error_response, problem_response, strip_container_prefix, validate_agent_name};
|
||||
use problem_details::ProblemDetails;
|
||||
|
||||
use super::{error_response, strip_container_prefix, validate_agent_name};
|
||||
use crate::lifecycle;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
@ -48,10 +50,9 @@ pub(super) async fn get_journal(
|
|||
let prefixed = format!("{}{container}", lifecycle::AGENT_PREFIX);
|
||||
let live = lifecycle::list().await.unwrap_or_default();
|
||||
if !live.iter().any(|c| c == &prefixed) {
|
||||
return problem_response(
|
||||
StatusCode::NOT_FOUND,
|
||||
&format!("journal: no managed container {prefixed:?}"),
|
||||
);
|
||||
return ProblemDetails::from_status_code(StatusCode::NOT_FOUND)
|
||||
.with_detail(format!("journal: no managed container {prefixed:?}"))
|
||||
.into_response();
|
||||
}
|
||||
let lines = q.lines.unwrap_or(500).min(5000);
|
||||
let unit = match q.unit.as_deref().filter(|s| !s.is_empty()) {
|
||||
|
|
@ -64,10 +65,9 @@ pub(super) async fn get_journal(
|
|||
format!("{u}.service")
|
||||
};
|
||||
if !allowed.contains(&unit.as_str()) {
|
||||
return problem_response(
|
||||
StatusCode::BAD_REQUEST,
|
||||
&format!("journal: unknown unit {unit:?}"),
|
||||
);
|
||||
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
|
||||
.with_detail(format!("journal: unknown unit {unit:?}"))
|
||||
.into_response();
|
||||
}
|
||||
Some(unit)
|
||||
}
|
||||
|
|
@ -127,10 +127,9 @@ pub(super) async fn get_journal_host(
|
|||
format!("{u}.service")
|
||||
};
|
||||
if !allowed.contains(&unit.as_str()) {
|
||||
return problem_response(
|
||||
StatusCode::BAD_REQUEST,
|
||||
&format!("journal-host: unknown unit {unit:?}"),
|
||||
);
|
||||
return ProblemDetails::from_status_code(StatusCode::BAD_REQUEST)
|
||||
.with_detail(format!("journal-host: unknown unit {unit:?}"))
|
||||
.into_response();
|
||||
}
|
||||
cmd.args(["-u", &unit]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue