Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 24, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/41ce708d8ead3b71800b4d1ba1513a69 to your computer and use it in GitHub Desktop.
Save rust-play/41ce708d8ead3b71800b4d1ba1513a69 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
use serde::Serialize;
#[derive(Serialize)]
enum Token {
S(String),
_I(i32),
}
#[derive(Serialize)]
struct Foo {
r#type: String,
token: Token,
challenge: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let params = Foo {
token: Token::S("abc".to_string()),
challenge: "def".to_string(),
r#type: "ghi".to_string(),
};
let client = reqwest::Client::new();
let resp = client
.post("http://127.0.0.1:8080/foo")
.form(&params)
.send()
.await?;
println!("{:#?}", resp);
println!("{:?}", resp.text().await);
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment