You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
557 B
Rust
21 lines
557 B
Rust
extern crate reqwest;
|
|
|
|
use rocket::serde::json::{Value};
|
|
use reqwest::{RequestBuilder, Client};
|
|
use std::env;
|
|
|
|
pub async fn build_rpc(method: &str, raw_data: Option<Value>, raw: bool) -> RequestBuilder {
|
|
let http_client = Client::new();
|
|
let daemon_uri = env::var("DAEMON_URI").unwrap();
|
|
let uri = if raw {
|
|
format!("{}/{}", &daemon_uri, &method)
|
|
} else {
|
|
format!("{}/json_rpc", &daemon_uri)
|
|
};
|
|
if let None = raw_data {
|
|
http_client.post(&uri)
|
|
} else {
|
|
http_client.post(&uri).json(&raw_data)
|
|
}
|
|
}
|