diff --git a/warzone/crates/warzone-server/src/routes/keys.rs b/warzone/crates/warzone-server/src/routes/keys.rs index 44a404f..5ca1c0f 100644 --- a/warzone/crates/warzone-server/src/routes/keys.rs +++ b/warzone/crates/warzone-server/src/routes/keys.rs @@ -11,7 +11,7 @@ pub fn routes() -> Router { 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, ) -> Result, 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 = 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) + } } } diff --git a/warzone/crates/warzone-server/src/routes/messages.rs b/warzone/crates/warzone-server/src/routes/messages.rs index 89b6b65..f026d71 100644 --- a/warzone/crates/warzone-server/src/routes/messages.rs +++ b/warzone/crates/warzone-server/src/routes/messages.rs @@ -11,8 +11,8 @@ use crate::state::AppState; pub fn routes() -> Router { 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)]