diff --git a/Cargo.toml b/Cargo.toml index 71d0c8da5eb394e1c6149b593026463c27cf7dfb..a5ae3a04f5508a90cc829572425c9af4f0e33d94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,4 @@ lru_time_cache = "0.11.11" humantime = "2.1.0" config = "0.13.3" serde_with = "2.3.1" -actix-cors = "0.6.4" \ No newline at end of file +actix-cors = "0.6.4" diff --git a/README.md b/README.md index 17f426706eb34cfebb21098c3e14844618c0748c..fea552f64fb45b61a801b5b86dff2fd1a3effedf 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ OPERATOR_MESSAGE: Customizable message from the operator (default: "Drone by Dea HAF_ENDPOINT: HAF Endpoint that Drone can connect to relay HAF related API calls. HAFAH_ENDPOINT: HAFAH Endpoint that Drone can connect to relay HAFAH related API calls. HIVEMIND_ENDPOINT: Hivemind Endpoint that Drone can connect to relay Hivemind related API calls. +ACTIX_CONNECTION_THREADS: Specifies the number of HTTP connections kept alive (default: 8). ``` ## Usage diff --git a/src/main.rs b/src/main.rs index 2ff6b2a4bd341df1dc18ac24930116533087217b..b4cce0678036a0931c51c6625ba18479aae30f68 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,9 +171,9 @@ async fn handle_request( // build result with data from cache and response let result = cached_call.clone(); return Ok(APICallResponse { - id: request.id, jsonrpc: request.jsonrpc.clone(), result: result["result"].clone(), + id: request.id, cached: true, }); } @@ -208,7 +208,7 @@ async fn handle_request( Ok(parsed) => parsed, Err(err) => { return Err(ErrorStructure { - code: 3000, + code: -32602, message: format!("Unable to parse endpoint data."), error: ErrorField::Message(err.to_string()), }) @@ -216,7 +216,7 @@ async fn handle_request( }; if json_body["error"].is_object() { return Err(ErrorStructure { - code: -32602, + code: -32700, message: format!("Endpoint returned an error."), error: ErrorField::Object(json_body["error"].clone()), }); @@ -236,9 +236,9 @@ async fn handle_request( .insert(request.params.to_string(), json_body.clone()); } Ok(APICallResponse { - id: request.id, jsonrpc: request.jsonrpc.clone(), result: json_body["result"].clone(), + id: request.id, cached: false, }) } @@ -288,8 +288,8 @@ async fn api_call( if requests.len() > 100 { return HttpResponse::InternalServerError().json(ErrorStructure { code: -32600, - message: "Internal Server Error".to_string(), - error: ErrorField::Message("Batch size too large.".to_string()), + message: "Request parameter error.".to_string(), + error: ErrorField::Message("Batch size too large, maximum allowed is 100.".to_string()), }); } @@ -307,9 +307,9 @@ async fn api_call( cached = false; } result.push(serde_json::json!({ - "id": response.id, "jsonrpc": response.jsonrpc, "result": response.result, + "id": response.id, })); } HttpResponse::Ok()