blob: 74d62cedf9af38f9dde0b7ab7d25844466275830 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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")?)
}
}
|