Skip to main content

srv_get_json

Function srv_get_json 

Source
pub(crate) async fn srv_get_json(
    client: &Client,
    url: &str,
    auth_key: &str,
    query: &[(&str, String)],
    what: &str,
) -> Result<Value>
Expand description

GET a srv route and return its JSON body, with every failure described by what actually happened (#3473). reqwest’s own message for a refused connection or a timeout is only “error sending request for url (…)”, which reads like a network fault whatever the cause; and parsing the body before checking the status loses the status whenever an error body isn’t JSON. So: refused / timed out / other transport failures are told apart, the status is checked first, and an error carries srv’s own error message, else the raw body.