diff options
author | David Knaack <davidkna@users.noreply.github.com> | 2020-01-19 17:00:40 +0100 |
---|---|---|
committer | Matan Kushner <hello@matchai.me> | 2020-01-19 11:00:40 -0500 |
commit | d869b3a09870d432a71d63623bb235b5345e680f (patch) | |
tree | 8c6598b874a8e0c0beb48488834626350932b8f3 /src/bug_report.rs | |
parent | 6a9eaa90b5cfcb7e1540adbc17f0dde10502cd06 (diff) |
refactor: replace reqwest with ureq (#844)
Diffstat (limited to 'src/bug_report.rs')
-rw-r--r-- | src/bug_report.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/bug_report.rs b/src/bug_report.rs index 8e53c4e14..1b43d26e1 100644 --- a/src/bug_report.rs +++ b/src/bug_report.rs @@ -1,7 +1,8 @@ use crate::utils::exec_cmd; -use reqwest; +use serde_urlencoded; use std::fs; use std::path::PathBuf; +use ureq; const GIT_IO_BASE_URL: &str = "https://git.io/"; @@ -16,18 +17,22 @@ pub fn create() { starship_config: get_starship_config(), }; - let link = make_github_issue_link(crate_version!(), environment); + let mut link = make_github_issue_link(crate_version!(), environment); if open::that(&link).is_ok() { print!("Take a look at your browser. A GitHub issue has been populated with your configuration") } else { - let link = reqwest::blocking::Client::new() - .post(&format!("{}{}", GIT_IO_BASE_URL, "create")) - .form(&[("url", &link)]) - .send() - .and_then(|response| response.text()) - .map(|slug| format!("{}{}", GIT_IO_BASE_URL, slug)) - .unwrap_or(link); + let data = serde_urlencoded::to_string(&[("url", &link)]); + if let Ok(data) = data { + let short_link = ureq::post(&format!("{}{}", GIT_IO_BASE_URL, "create")) + .set("Content-Type", "application/x-www-form-urlencoded") + .send_string(&data) + .into_string() + .map(|slug| format!("{}{}", GIT_IO_BASE_URL, slug)); + if let Ok(short_link) = short_link { + link = short_link; + } + } println!( "Click this link to create a GitHub issue populated with your configuration:\n\n {}", |