From 666a423cbf356a95f42856f3945dbb1c8e770a19 Mon Sep 17 00:00:00 2001 From: Zhen Lu Date: Tue, 19 Mar 2024 19:19:45 -0700 Subject: [PATCH] Modify the signer example to add an option to return directly. --- .../lightspark-remote-signing-server/src/config.rs | 3 +++ examples/lightspark-remote-signing-server/src/main.rs | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/examples/lightspark-remote-signing-server/src/config.rs b/examples/lightspark-remote-signing-server/src/config.rs index 5f9ce96..5e4c67a 100644 --- a/examples/lightspark-remote-signing-server/src/config.rs +++ b/examples/lightspark-remote-signing-server/src/config.rs @@ -6,6 +6,7 @@ pub struct Config { pub webhook_secret: String, pub master_seed_hex: String, pub api_port: u16, + pub respond_directly: bool, } impl Config { @@ -16,6 +17,7 @@ impl Config { let webhook_secret = std::env::var("RK_WEBHOOK_SECRET").ok(); let master_seed_hex = std::env::var("RK_MASTER_SEED_HEX").ok(); let api_port = std::env::var("PORT").ok(); + let respond_directly = std::env::var("RESPOND_DIRECTLY").is_ok(); Self { api_endpoint, @@ -27,6 +29,7 @@ impl Config { .unwrap_or("8080".to_string()) .parse() .expect("api port"), + respond_directly, } } } diff --git a/examples/lightspark-remote-signing-server/src/main.rs b/examples/lightspark-remote-signing-server/src/main.rs index d93cb89..6dd9872 100644 --- a/examples/lightspark-remote-signing-server/src/main.rs +++ b/examples/lightspark-remote-signing-server/src/main.rs @@ -61,6 +61,16 @@ async fn webhook_handler( debug!("Response {:?}", response); + if data.respond_directly { + let json_payload = lightspark::request::requester::build_graphql_request_body( + &response.query, + Some(response.variables), + false, + ) + .unwrap(); + return HttpResponse::Ok().json(json_payload); + } + let result = client .execute_graphql_request_variable(&response.query, response.variables) .await;