blob: 88944ef873de3c317405bb39e72d1a856e274356 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct GuzzleResponse {
pub url: String,
}
const GUZZLE: &str = "http://198.199.68.30";
pub async fn get_random_teawie() -> String {
let endpoint = "/get_random_teawie";
let resp = reqwest::get(GUZZLE.to_owned() + endpoint).await.unwrap(); // why did i have to own
// this constant? i have
// no idea!
let err_msg = "couldn't get a teawie";
match resp.status() {
StatusCode::OK => match resp.json::<GuzzleResponse>().await {
Ok(data) => data.url,
Err(why) => format!("{} ({:?})", err_msg, why),
},
other => format!("{} ({:?})", err_msg, other),
}
}
|