diff options
| author | Max Audron <audron@cocaine.farm> | 2021-10-22 19:08:59 +0200 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2021-10-22 19:09:39 +0200 |
| commit | 309899168a086de88acf97fd6683387a7af7078c (patch) | |
| tree | 846075c1e9af0d7139edae5597f1147b851ed2b2 /src/util/web/url_shorteners.rs | |
| parent | remove wolfram alpha url shortening (diff) | |
write tons of documentation and reorganize some modules
Diffstat (limited to 'src/util/web/url_shorteners.rs')
| -rw-r--r-- | src/util/web/url_shorteners.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/web/url_shorteners.rs b/src/util/web/url_shorteners.rs new file mode 100644 index 0000000..74d62ce --- /dev/null +++ b/src/util/web/url_shorteners.rs @@ -0,0 +1,21 @@ +use anyhow::{Context, Error, Result}; +use async_trait::async_trait; +use reqwest::{get, Url}; + +pub struct Isgd; + +#[async_trait] +impl super::UrlShortener for Isgd { + async fn shorten(url: &str) -> Result<String, Error> { + Ok(get(Url::parse(&format!( + "https://is.gd/create.php?format=simple&url={}", + url + )) + .context("Failed to parse url")?) + .await + .context("Failed to make request")? + .text() + .await + .context("failed to get request response text")?) + } +} |
