m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-16 17:13:46 -05:00

Switch back to json

This commit is contained in:
Sergio
2024-07-17 15:28:32 +03:00
parent d1cb62304d
commit 1cf4cf2394
7 changed files with 47 additions and 72 deletions

View File

@@ -1,7 +1,7 @@
use std::sync::Mutex;
use json::JsonValue;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use serde_json::Value;
use ureq::Error;
use http_auth::parse_challenges;
@@ -95,18 +95,13 @@ pub fn get_token(images: Vec<&Image>, auth_url: &str) -> String {
error!("Token request failed!\n{}", e)
}
};
let parsed_token_response: Value = match serde_json::from_str(&raw_response) {
let parsed_token_response: JsonValue = match json::parse(&raw_response) {
Ok(parsed) => parsed,
Err(e) => {
error!("Failed to parse server response\n{}", e)
}
};
parsed_token_response
.get("token")
.unwrap()
.as_str()
.unwrap()
.to_string()
parsed_token_response["token"].to_string()
}
fn parse_www_authenticate(www_auth: &str) -> String {