feat: add /api/v1/trace-profile-file endpoint
- Added endpoint to serve trace_profile.json files - Fixes Studio proxy bug (missing file_uuid in path) - Studio proxy at proxy.rs:809 constructs path without file_uuid - Core endpoint now provides correct implementation - Studio can proxy to this endpoint instead of local file reading
This commit is contained in:
@@ -70,6 +70,10 @@ pub fn trace_agent_routes() -> Router<crate::api::types::AppState> {
|
||||
"/api/v1/file/:file_uuid/trace/:trace_id/regenerate-thumbnail",
|
||||
post(regenerate_trace_thumbnail),
|
||||
)
|
||||
.route(
|
||||
"/api/v1/trace-profile-file",
|
||||
get(get_trace_profile_file),
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -2729,3 +2733,23 @@ fn read_trace_profile(file_uuid: &str, trace_id: i32) -> Option<serde_json::Valu
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// GET /api/v1/trace-profile-file?file_uuid=...&trace_id=...
|
||||
/// Returns the trace_profile.json for a given file and trace.
|
||||
async fn get_trace_profile_file(
|
||||
Query(params): Query<std::collections::HashMap<String, String>>,
|
||||
) -> impl IntoResponse {
|
||||
let file_uuid = match params.get("file_uuid") {
|
||||
Some(v) => v.clone(),
|
||||
None => return (StatusCode::BAD_REQUEST, Json(serde_json::json!({"error": "Missing file_uuid"}))),
|
||||
};
|
||||
let trace_id: i32 = match params.get("trace_id").and_then(|v| v.parse().ok()) {
|
||||
Some(v) => v,
|
||||
None => return (StatusCode::BAD_REQUEST, Json(serde_json::json!({"error": "Missing or invalid trace_id"}))),
|
||||
};
|
||||
|
||||
match read_trace_profile(&file_uuid, trace_id) {
|
||||
Some(profile) => (StatusCode::OK, Json(profile)),
|
||||
None => (StatusCode::NOT_FOUND, Json(serde_json::json!({"error": "Trace profile file not found", "file_uuid": file_uuid, "trace_id": trace_id}))),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user