clean match and replace it with .unwrap_or_else
This commit is contained in:
parent
c2715d1fb6
commit
e422785583
22
src/limit.rs
22
src/limit.rs
|
@ -33,15 +33,19 @@ impl LimitedRequester {
|
||||||
pub async fn check_limits(url: String) -> Vec<Limit> {
|
pub async fn check_limits(url: String) -> Vec<Limit> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let url_parsed = crate::URLBundle::parse_url(url) + "/api/policies/instance/limits";
|
let url_parsed = crate::URLBundle::parse_url(url) + "/api/policies/instance/limits";
|
||||||
let result = match client.get(url_parsed).send().await {
|
let result = client
|
||||||
Ok(response) => match response.text().await {
|
.get(url_parsed)
|
||||||
Ok(string) => string,
|
.send()
|
||||||
Err(e) => panic!("Error encountered during request body parsing: {}", e),
|
.await
|
||||||
},
|
.unwrap_or_else(|e| panic!("An error occured while performing the request: {}", e))
|
||||||
Err(e) => {
|
.text()
|
||||||
panic!("Error encountered during performing the request: {}", e)
|
.await
|
||||||
}
|
.unwrap_or_else(|e| {
|
||||||
};
|
panic!(
|
||||||
|
"An error occured while parsing the request body string: {}",
|
||||||
|
e
|
||||||
|
)
|
||||||
|
});
|
||||||
/*
|
/*
|
||||||
2. extract rate and absolute rate limits from response result
|
2. extract rate and absolute rate limits from response result
|
||||||
3. put each different rate limit as a new object in the limit vector
|
3. put each different rate limit as a new object in the limit vector
|
||||||
|
|
Loading…
Reference in New Issue