This commit is contained in:
parent
9de05362be
commit
6299bb5ab3
2 changed files with 7 additions and 3 deletions
|
|
@ -11,3 +11,4 @@ serde = { version = "1.0", features = ["derive"] }
|
|||
serde_json = "1.0"
|
||||
reqwest = { version = "0.13.0", features = ["json"] }
|
||||
bytes = "1"
|
||||
urlencoding = "2.1.3"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use bytes::Bytes;
|
|||
static MII_RENDERER_URL: &str = "https://mii-renderer.bloxerhd.co.uk";
|
||||
|
||||
async fn request_mii_render(client: &State<Client>, mii_data: &str, ext: &str) -> Result<Bytes, (Status, String)> {
|
||||
let mii_data = urlencoding::encode(mii_data);
|
||||
let req_str = format!("{MII_RENDERER_URL}/miis/image.{ext}?data={mii_data}");
|
||||
|
||||
let response = client.get(req_str)
|
||||
|
|
@ -59,7 +60,7 @@ pub async fn mii_render(pid: i32, path: &str, client: &State<Client>) -> Result<
|
|||
if !status.is_success() {
|
||||
let text = res.text().await.unwrap_or_default();
|
||||
|
||||
return Err((Status::new(status.as_u16()), format!("Error Returned from Renderer: {text}")))
|
||||
return Err((Status::new(status.as_u16()), format!("Error Returned from Account while fetching Mii Data: {text}")))
|
||||
}
|
||||
|
||||
res
|
||||
|
|
@ -70,11 +71,13 @@ pub async fn mii_render(pid: i32, path: &str, client: &State<Client>) -> Result<
|
|||
}
|
||||
};
|
||||
|
||||
let data: String = match response.json().await {
|
||||
let mut data: String = match response.json().await {
|
||||
Ok(data) => data,
|
||||
Err(e) => return Err((Status::new(e.status().unwrap().as_u16()), "Error Parsing Json Response when fetching Mii Data".into())),
|
||||
};
|
||||
|
||||
data.retain(|c| !c.is_whitespace());
|
||||
|
||||
data
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue