style(sidecar): apply rustfmt

Format the sidecar source with `cargo fmt` so the new `cargo fmt --check`
CI gate passes on the first run. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0114TpmrNW4wNXsHq5CR72jQ
This commit is contained in:
2026-07-13 14:40:05 -05:00
parent c515a86a87
commit 359bb937b2
5 changed files with 38 additions and 18 deletions

View File

@@ -123,7 +123,8 @@ fn iso_ms(ms: i64) -> Option<String> {
if ms <= 0 {
return None;
}
chrono::DateTime::from_timestamp_millis(ms).map(|dt| dt.format("%Y-%m-%dT%H:%M:%SZ").to_string())
chrono::DateTime::from_timestamp_millis(ms)
.map(|dt| dt.format("%Y-%m-%dT%H:%M:%SZ").to_string())
}
// ---- gate: protocol check + auth ----
@@ -174,8 +175,15 @@ async fn gate(State(st): State<AppState>, req: Request, next: Next) -> Response
fn extract_token(req: &Request) -> Option<String> {
// Authorization: Bearer <token>
if let Some(v) = req.headers().get("authorization").and_then(|h| h.to_str().ok()) {
if let Some(rest) = v.strip_prefix("Bearer ").or_else(|| v.strip_prefix("bearer ")) {
if let Some(v) = req
.headers()
.get("authorization")
.and_then(|h| h.to_str().ok())
{
if let Some(rest) = v
.strip_prefix("Bearer ")
.or_else(|| v.strip_prefix("bearer "))
{
return Some(rest.trim().to_string());
}
}
@@ -349,7 +357,10 @@ async fn page_respond(
Path(id): Path<String>,
Json(body): Json<Value>,
) -> impl IntoResponse {
let message = body.get("message").and_then(|m| m.as_str()).unwrap_or_default();
let message = body
.get("message")
.and_then(|m| m.as_str())
.unwrap_or_default();
if message.trim().is_empty() {
return (
StatusCode::BAD_REQUEST,
@@ -439,7 +450,10 @@ async fn vendors(State(st): State<AppState>, Path(account): Path<String>) -> imp
/// Body: {"code":"AB12CD","websiteUserId":"9931"}. Correlated on `code`.
async fn link_confirm(State(st): State<AppState>, Json(body): Json<Value>) -> impl IntoResponse {
let code = body.get("code").and_then(|c| c.as_str()).unwrap_or_default();
let code = body
.get("code")
.and_then(|c| c.as_str())
.unwrap_or_default();
let web_id = body
.get("websiteUserId")
.and_then(|w| w.as_str())
@@ -501,10 +515,7 @@ async fn towncrier_add(State(st): State<AppState>, Json(body): Json<Value>) -> i
respond(st.rpc.call(&st.shard, cmd, &id).await)
}
async fn towncrier_remove(
State(st): State<AppState>,
Path(id): Path<String>,
) -> impl IntoResponse {
async fn towncrier_remove(State(st): State<AppState>, Path(id): Path<String>) -> impl IntoResponse {
let cmd = json!({"kind":"towncrier.remove","id":id});
respond(st.rpc.call(&st.shard, cmd, &id).await)
}