From 30b76f69ce069afaf855c836b339c8a031715f1f Mon Sep 17 00:00:00 2001 From: crunk Date: Sun, 24 Sep 2023 10:40:08 +0200 Subject: [PATCH] reqwest using a client with post request --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8216767..b27c0c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,20 +7,20 @@ use clap::Parser; struct Cli { url: String, + text: String, } -// This is using the `tokio` runtime. You'll need the following dependency: -// -// `tokio = { version = "1", features = ["full"] }` #[cfg(not(target_arch = "wasm32"))] #[tokio::main] + async fn main() -> Result<(), reqwest::Error> { // Some simple CLI args requirements... let args = Cli::parse(); let url = args.url; + let text = args.text; - eprintln!("Fetching {:?}...", url); - let res = reqwest::get(url).await?; + let client = reqwest::Client::new(); + let res = client.post(url).body(text).send().await?; eprintln!("Response: {:?} {}", res.version(), res.status()); eprintln!("Headers: {:#?}\n", res.headers());