From 86e2d5e3fa127de7ba9d8bbc44e56ec59bc458e2 Mon Sep 17 00:00:00 2001 From: Zhen Lu Date: Wed, 20 Mar 2024 16:38:07 -0700 Subject: [PATCH] Modify the signer example to add an option to return directly. (#40) --- examples/lightspark-remote-signing-server/src/config.rs | 3 +++ examples/lightspark-remote-signing-server/src/main.rs | 4 ++++ 2 files changed, 7 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..feda4ed 100644 --- a/examples/lightspark-remote-signing-server/src/main.rs +++ b/examples/lightspark-remote-signing-server/src/main.rs @@ -61,6 +61,10 @@ async fn webhook_handler( debug!("Response {:?}", response); + if data.respond_directly { + return HttpResponse::Ok().json(response.variables); + } + let result = client .execute_graphql_request_variable(&response.query, response.variables) .await;