Created
January 24, 2020 13:33
-
-
Save rust-play/41ce708d8ead3b71800b4d1ba1513a69 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(¶ms) | |
.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