Add request tracing, debug /v1/keys/list endpoint
- TraceLayer logs every HTTP request (method, path, status, duration) - Default log level info, tower_http=debug (no RUST_LOG needed) - GET /v1/keys/list shows all registered fingerprints - Helps debug key registration and lookup issues Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,9 +10,25 @@ use crate::state::AppState;
|
||||
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))
|
||||
}
|
||||
|
||||
/// Debug endpoint: list all registered fingerprints.
|
||||
async fn list_keys(State(state): State<AppState>) -> Json<serde_json::Value> {
|
||||
let keys: Vec<String> = state
|
||||
.db
|
||||
.keys
|
||||
.iter()
|
||||
.filter_map(|item| {
|
||||
item.ok()
|
||||
.and_then(|(k, _)| String::from_utf8(k.to_vec()).ok())
|
||||
})
|
||||
.collect();
|
||||
tracing::info!("Listed {} registered keys", keys.len());
|
||||
Json(serde_json::json!({ "keys": keys, "count": keys.len() }))
|
||||
}
|
||||
|
||||
/// Normalize fingerprint: strip colons, lowercase.
|
||||
fn normalize_fp(fp: &str) -> String {
|
||||
fp.chars()
|
||||
|
||||
Reference in New Issue
Block a user