pub async fn process_jsonrpc_request(
    jsonrpc_req: JsonRpcRequest,
    safe_auth_handle: SharedSafeAuthenticatorHandle,
    auth_reqs_handle: SharedAuthReqsHandle,
    notif_endpoints_handle: SharedNotifEndpointsHandle,
) -> Result<JsonRpcResponse, Error> {
    info!(
        "Processing new incoming request ({}): '{}'",
        jsonrpc_req.id, jsonrpc_req.method
    );

    let params = jsonrpc_req.params;
    let outcome = match jsonrpc_req.method.as_str() {
        METHOD_STATUS => {
            status::process_req(
                params,
                safe_auth_handle,
                auth_reqs_handle,
                notif_endpoints_handle,
            )
            .await
        }
        METHOD_UNLOCK => unlock::process_req(params, safe_auth_handle).await,
        METHOD_LOCK => lock::process_req(params, safe_auth_handle, auth_reqs_handle).await,
        METHOD_CREATE => create::process_req(params, safe_auth_handle).await,
        METHOD_AUTHED_APPS => authed_apps::process_req(params, safe_auth_handle).await,
        METHOD_REVOKE => revoke::process_req(params, safe_auth_handle).await,
        METHOD_AUTH_REQS => auth_reqs::process_req(params, auth_reqs_handle).await,
        METHOD_ALLOW => allow::process_req(params, auth_reqs_handle).await,
        METHOD_DENY => deny::process_req(params, auth_reqs_handle).await,
        METHOD_SUBSCRIBE => subscribe::process_req(params, notif_endpoints_handle).await,
        METHOD_UNSUBSCRIBE => unsubscribe::process_req(params, notif_endpoints_handle).await,
        METHOD_AUTHORISE => {
            authorise::process_req(params, safe_auth_handle.clone(), auth_reqs_handle.clone()).await
        }
        other => {
            let msg = format!(
                "Method '{}' not supported or unknown by the Authenticator daemon",
                other
            );
            error!("{}", msg);
            Err(msg)
        }
    };

    // Return a JsonRpcResponse containing either a result or an error according to the outcome
    match outcome {
        Ok(result) => Ok(JsonRpcResponse::result(result, jsonrpc_req.id)),
        Err(err_msg) => {
            error!(
                "Error when processing incoming '{}' request with id {}: {}",
                jsonrpc_req.method, jsonrpc_req.id, err_msg
            );
            Ok(JsonRpcResponse::error(
                err_msg,
                JSONRPC_AUTH_ERROR,
                Some(jsonrpc_req.id),
            ))
        }
    }
}
// Process the JSON-RPC request based on the method
Process the JSON-RPC request based on the method
Process the JSON - RPC request based on the method
pub async fn process_jsonrpc_request(
    jsonrpc_req: JsonRpcRequest,
    safe_auth_handle: SharedSafeAuthenticatorHandle,
    auth_reqs_handle: SharedAuthReqsHandle,
    notif_endpoints_handle: SharedNotifEndpointsHandle,
) -> Result<JsonRpcResponse, Error> {
    info!(
        "Processing new incoming request ({}): '{}'",
        jsonrpc_req.id, jsonrpc_req.method
    );
    let params = jsonrpc_req.params;
    let outcome = match jsonrpc_req.method.as_str() {
        METHOD_STATUS => {
            status::process_req(
                params,
                safe_auth_handle,
                auth_reqs_handle,
                notif_endpoints_handle,
            )
            .await
        }
        METHOD_UNLOCK => unlock::process_req(params, safe_auth_handle).await,
        METHOD_LOCK => lock::process_req(params, safe_auth_handle, auth_reqs_handle).await,
        METHOD_CREATE => create::process_req(params, safe_auth_handle).await,
        METHOD_AUTHED_APPS => authed_apps::process_req(params, safe_auth_handle).await,
        METHOD_REVOKE => revoke::process_req(params, safe_auth_handle).await,
        METHOD_AUTH_REQS => auth_reqs::process_req(params, auth_reqs_handle).await,
        METHOD_ALLOW => allow::process_req(params, auth_reqs_handle).await,
        METHOD_DENY => deny::process_req(params, auth_reqs_handle).await,
        METHOD_SUBSCRIBE => subscribe::process_req(params, notif_endpoints_handle).await,
        METHOD_UNSUBSCRIBE => unsubscribe::process_req(params, notif_endpoints_handle).await,
        METHOD_AUTHORISE => {
            authorise::process_req(params, safe_auth_handle.clone(), auth_reqs_handle.clone()).await
        }
        other => {
            let msg = format!(
                "Method '{}' not supported or unknown by the Authenticator daemon",
                other
            );
            error!("{}", msg);
            Err(msg)
        }
    };
    // Return a JsonRpcResponse containing either a result or an error according to the outcome
    match outcome {
        Ok(result) => Ok(JsonRpcResponse::result(result, jsonrpc_req.id)),
        Err(err_msg) => {
            error!(
                "Error when processing incoming '{}' request with id {}: {}",
                jsonrpc_req.method, jsonrpc_req.id, err_msg
            );
            Ok(JsonRpcResponse::error(
                err_msg,
                JSONRPC_AUTH_ERROR,
                Some(jsonrpc_req.id),
            ))
        }
    }
}
pub async fn process_jsonrpc_request ( jsonrpc_req : JsonRpcRequest , safe_auth_handle : SharedSafeAuthenticatorHandle , auth_reqs_handle : SharedAuthReqsHandle , notif_endpoints_handle : SharedNotifEndpointsHandle , ) -> Result < JsonRpcResponse , Error > { info ! ( " " jsonrpc_req id jsonrpc_req method ) ; let params = jsonrpc_req . params ; let outcome = match jsonrpc_req . method . as_str ( ) { METHOD_STATUS => { status :: process_req ( params , safe_auth_handle , auth_reqs_handle , notif_endpoints_handle , ) . await } METHOD_UNLOCK => unlock :: process_req ( params , safe_auth_handle ) . await , METHOD_LOCK => lock :: process_req ( params , safe_auth_handle , auth_reqs_handle ) . await , METHOD_CREATE => create :: process_req ( params , safe_auth_handle ) . await , METHOD_AUTHED_APPS => authed_apps :: process_req ( params , safe_auth_handle ) . await , METHOD_REVOKE => revoke :: process_req ( params , safe_auth_handle ) . await , METHOD_AUTH_REQS => auth_reqs :: process_req ( params , auth_reqs_handle ) . await , METHOD_ALLOW => allow :: process_req ( params , auth_reqs_handle ) . await , METHOD_DENY => deny :: process_req ( params , auth_reqs_handle ) . await , METHOD_SUBSCRIBE => subscribe :: process_req ( params , notif_endpoints_handle ) . await , METHOD_UNSUBSCRIBE => unsubscribe :: process_req ( params , notif_endpoints_handle ) . await , METHOD_AUTHORISE => { authorise :: process_req ( params , safe_auth_handle . clone ( ) , auth_reqs_handle . clone ( ) ) . await } other => { let msg = format ! ( " " other ) ; error ! ( " " msg ) ; Err ( msg ) } } ; // Return a JsonRpcResponse containing either a result or an error according to the outcome match outcome { Ok ( result ) => Ok ( JsonRpcResponse :: result ( result , jsonrpc_req . id ) ) , Err ( err_msg ) => { error ! ( " " jsonrpc_req method jsonrpc_req id err_msg ) ; Ok ( JsonRpcResponse :: error ( err_msg , JSONRPC_AUTH_ERROR , Some ( jsonrpc_req . id ) , ) ) } } }
Process the JSON-RPC request based on the method
Process the JSON - RPC request based on the method
jsonrpc_req
JsonRpcRequest
safe_auth_handle
SharedSafeAuthenticatorHandle
auth_reqs_handle
SharedAuthReqsHandle
notif_endpoints_handle
SharedNotifEndpointsHandle