Fix axum route params: use :param syntax (not {param}) for axum 0.7

Axum 0.7 uses :param for path parameters. {param} is axum 0.8+ syntax.
Routes were silently not matching, causing 404 on all key lookups.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-26 22:48:19 +04:00
parent bc64afcb05
commit 8a6eebabfd
2 changed files with 24 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ pub fn routes() -> Router<AppState> {
Router::new()
.route("/keys/register", post(register_keys))
.route("/keys/list", get(list_keys))
.route("/keys/{fingerprint}", get(get_bundle))
.route("/keys/:fingerprint", get(get_bundle))
}
/// Debug endpoint: list all registered fingerprints.
@@ -63,15 +63,29 @@ async fn get_bundle(
Path(fingerprint): Path<String>,
) -> Result<Json<serde_json::Value>, axum::http::StatusCode> {
let key = normalize_fp(&fingerprint);
tracing::info!("Looking up bundle for {}", key);
tracing::info!("get_bundle: raw path='{}', normalized='{}'", fingerprint, key);
// Debug: list what's in the DB
let all_keys: Vec<String> = state.db.keys.iter()
.filter_map(|r| r.ok().and_then(|(k, _)| String::from_utf8(k.to_vec()).ok()))
.collect();
tracing::info!("get_bundle: DB contains {} keys: {:?}", all_keys.len(), all_keys);
match state.db.keys.get(key.as_bytes()) {
Ok(Some(data)) => Ok(Json(serde_json::json!({
"fingerprint": fingerprint,
"bundle": base64::Engine::encode(&base64::engine::general_purpose::STANDARD, &data),
}))),
_ => {
tracing::warn!("Bundle not found for {}", key);
Ok(Some(data)) => {
tracing::info!("get_bundle: FOUND {} bytes for {}", data.len(), key);
Ok(Json(serde_json::json!({
"fingerprint": fingerprint,
"bundle": base64::Engine::encode(&base64::engine::general_purpose::STANDARD, &data),
})))
}
Ok(None) => {
tracing::warn!("get_bundle: NOT FOUND for key '{}'", key);
Err(axum::http::StatusCode::NOT_FOUND)
}
Err(e) => {
tracing::error!("get_bundle: DB error: {}", e);
Err(axum::http::StatusCode::INTERNAL_SERVER_ERROR)
}
}
}

View File

@@ -11,8 +11,8 @@ use crate::state::AppState;
pub fn routes() -> Router<AppState> {
Router::new()
.route("/messages/send", post(send_message))
.route("/messages/poll/{fingerprint}", get(poll_messages))
.route("/messages/{id}/ack", delete(ack_message))
.route("/messages/poll/:fingerprint", get(poll_messages))
.route("/messages/:id/ack", delete(ack_message))
}
#[derive(Deserialize)]