(
sender_client: Arc<backend::Client>,
bp: backend::BasePayload,
b: &[u8],
)
| 373 | } |
| 374 | |
| 375 | async fn handle_pr_stop_req( |
| 376 | sender_client: Arc<backend::Client>, |
| 377 | bp: backend::BasePayload, |
| 378 | b: &[u8], |
| 379 | ) -> Response { |
| 380 | if sender_client.is_async() { |
| 381 | let b = b.to_vec(); |
| 382 | task::spawn(async move { |
| 383 | let ans = match _handle_pr_stop_req(&b).await { |
| 384 | Ok(v) => v, |
| 385 | Err(e) => { |
| 386 | let msg = e.to_string(); |
| 387 | backend::PRStopAnsPayload { |
| 388 | base: bp.to_base_payload_result(err_to_result_code(e), &msg), |
| 389 | } |
| 390 | } |
| 391 | }; |
| 392 | |
| 393 | log_request_response(&bp, &b, &ans).await; |
| 394 | |
| 395 | if let Err(e) = sender_client.pr_stop_ans(backend::Role::SNS, &ans).await { |
| 396 | error!(error = %e.full(), "Send async PRStopAns error"); |
| 397 | } |
| 398 | }); |
| 399 | (StatusCode::OK, "").into_response() |
| 400 | } else { |
| 401 | match _handle_pr_stop_req(b).await { |
| 402 | Ok(ans) => { |
| 403 | log_request_response(&bp, b, &ans).await; |
| 404 | Json(&ans).into_response() |
| 405 | } |
| 406 | Err(e) => { |
| 407 | let ans = err_to_response(e, &bp); |
| 408 | log_request_response(&bp, b, &ans).await; |
| 409 | Json(&ans).into_response() |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | async fn _handle_pr_stop_req(b: &[u8]) -> Result<backend::PRStopAnsPayload> { |
| 416 | let pl: backend::PRStopReqPayload = serde_json::from_slice(b)?; |
no test coverage detected