Skip to content

Commit

Permalink
0.0.4
Browse files Browse the repository at this point in the history
updated the optional inputs, added post support with :  matching synax right now. tested against a rust rocket server.
  • Loading branch information
Mooninghnk committed Oct 24, 2023
1 parent 1466c7e commit 4bec70e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ struct Args {
/// request type
#[arg(short, default_value_t = String::new())]
get: String,

#[arg(short)]
json: Option<String>,
/// count to run
#[arg(short, default_value_t = 1)]
count: u8,
Expand All @@ -25,6 +28,9 @@ fn main() {
if args.get.contains("get") || args.get.contains("Get") {
let resp = get_req(cmp);
println!("{:?}", resp);
} else if args.get.contains("post") || args.get.contains("Post") {
let jsn = args.json.as_deref().unwrap();
get_post(cmp, String::from(jsn));
}
}
}
Expand All @@ -34,6 +40,14 @@ async fn get_req(url: &str) -> Result<String, reqwest::Error> {
Ok(body)
}

#[tokio::main]
async fn get_post(url: &str, json: String) {
let spl: Vec<&str> = json.split(":").collect();
let json_data = format!(r#"{{"{}": "{}"}}"#, spl[0], spl[1]);
let client = reqwest::Client::new();

println!("{:?}", json_data);
}
//add post support with json
//transfer 25 into a fn
//update the instruction on usage
Expand Down

0 comments on commit 4bec70e

Please sign in to comment.