feat(#2302): migrate dashboard to the single hive-host-sock Ident newtype
This commit is contained in:
parent
384dcae5f4
commit
1286029947
10 changed files with 37 additions and 210 deletions
|
|
@ -19,8 +19,11 @@ use crate::lifecycle;
|
|||
mod approvals;
|
||||
mod build_logs;
|
||||
mod extra_forges;
|
||||
mod idents;
|
||||
pub(crate) use idents::AgentName;
|
||||
// The single validated identifier type — homed in `hive-host-sock` (the crate
|
||||
// owning agent-path facts) so every dashboard path-param validates through the
|
||||
// same type used to build agent paths. Re-exported so submodules + the socket
|
||||
// server reach it as `crate::dashboard::Ident`.
|
||||
pub(crate) use hive_host_sock::Ident;
|
||||
mod infra_containers;
|
||||
mod journal;
|
||||
mod lifecycle_ops;
|
||||
|
|
@ -296,7 +299,7 @@ fn try_bind(addr: SocketAddr) -> std::io::Result<tokio::net::TcpListener> {
|
|||
|
||||
/// Two-axis path-param guard for write routes. Combines:
|
||||
///
|
||||
/// 1. **format validation** ([`idents::AgentName::parse`]) — rejects
|
||||
/// 1. **format validation** ([`Ident::parse`]) — rejects
|
||||
/// path traversal / unicode homoglyphs / empty + too-long names with
|
||||
/// HTTP 400.
|
||||
/// 2. **existence check** — looks up `name` in the coordinator's
|
||||
|
|
@ -311,9 +314,9 @@ fn try_bind(addr: SocketAddr) -> std::io::Result<tokio::net::TcpListener> {
|
|||
/// handler taking a name path-param. Read-only GET handlers and
|
||||
/// handlers that legitimately operate on tombstoned agents (e.g.
|
||||
/// `mark-all-read` on broker rows for a destroyed agent) call
|
||||
/// [`idents::AgentName::parse`] directly and skip the existence check.
|
||||
/// [`Ident::parse`] directly and skip the existence check.
|
||||
async fn guard_agent_name(state: &AppState, name: &str) -> Option<Response> {
|
||||
if let Err(reason) = idents::AgentName::parse(name) {
|
||||
if let Err(reason) = Ident::parse(name) {
|
||||
return Some(
|
||||
(StatusCode::BAD_REQUEST, format!("bad agent name: {reason}")).into_response(),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue