userspace:webservice_corner:rust-rpc
This is an old revision of the document!
This script uses reqwest. Add the following to your `Cargo.toml`:
[dependencies] reqwest = "0.9.9"
The main.rs looks like this:
extern crate reqwest;
use std::collections::HashMap;
fn main() -> Result<(), Box<std::error::Error>> {
let mut jrpc = HashMap::new();
jrpc.insert("id", "1");
jrpc.insert("method", "backend_info");
jrpc.insert("params", "");
let client = reqwest::Client::new();
let mut response = client.post("https://bonifax.uib.local:4447/rpc")
.basic_auth("adminuser", Some("linux123"))
.json(&jrpc)
.send()?;
println!("Headers: {:#?}", response);
let content = response.text()?;
println!("Body: {:#?}", content);
Ok(())
}
userspace/webservice_corner/rust-rpc.1550501876.txt.gz · Last modified: (external edit)
