Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the signer example to add an option to return directly. #39

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/lightspark-remote-signing-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -27,6 +29,7 @@ impl Config {
.unwrap_or("8080".to_string())
.parse()
.expect("api port"),
respond_directly,
}
}
}
10 changes: 10 additions & 0 deletions examples/lightspark-remote-signing-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading