aboutsummaryrefslogtreecommitdiff
path: root/src/util/web.rs
blob: 77e20a3e15cc01fee62c5d076df05e68b0c91604 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use anyhow::{Context, Error, Result};
use reqwest::{get, Url};

// TODO: Either catinator should have a URL shortening utility module,
// or we should start our own service
pub(crate) async fn shorten_url(url: &str) -> Result<String, Error> {
    // This just uses the first service gonzobot uses too
    let short_url = 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")?;

    Ok(short_url)
}
ss='insertions'>+9 2024-02-21set minecraft memoryMax Audron-0/+1 2024-02-21add minecraft server and move palworld to games moduleMax Audron-3/+56 2024-02-21set network manually for ns serversMax Audron-0/+51 2024-02-20update nixpkgs-unstableMax Audron-3/+3 2024-02-19update d3fus fritzbox wg portMarcin Maselko-1/+1 2024-02-19add xonotic serverMax Audron-1/+10