Skip to content

Commit

Permalink
Use Result for process_analysis_request.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonforal committed Nov 6, 2024
1 parent b5bdd4b commit 343be2d
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 228 deletions.
10 changes: 9 additions & 1 deletion crates/bins/src/bin/datadog_static_analyzer_server/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use rocket::{
serde::json::{json, Json, Value},
Build, Rocket, Shutdown, State,
};
use server::model::analysis_response::AnalysisResponse;
use server::model::{
analysis_request::AnalysisRequest, tree_sitter_tree_request::TreeSitterRequest,
};
Expand Down Expand Up @@ -109,7 +110,14 @@ fn languages(span: TraceSpan) -> Value {
fn analyze(span: TraceSpan, request: Json<AnalysisRequest>) -> Value {
let _entered = span.enter();
tracing::debug!("{:?}", &request.0);
json!(process_analysis_request(request.into_inner()))
let (rule_responses, errors) = match process_analysis_request(request.into_inner()) {
Ok(rule_responses) => (rule_responses, vec![]),
Err(err) => (vec![], vec![err]),
};
json!(AnalysisResponse {
rule_responses,
errors
})
}

#[rocket::post("/get-treesitter-ast", format = "application/json", data = "<request>")]
Expand Down
Loading

0 comments on commit 343be2d

Please sign in to comment.