pub(crate) fn parse_response<T: serde::de::DeserializeOwned>(
    resp: &HttpResponse,
) -> Result<T, RequestParseError> {
    let body = parse_token_response_raw(resp)?.body();
    if let Some(_content) = resp.headers().get(http::header::CONTENT_TYPE) {
        // TODO: Remove this cfg, see issue https://github.com/twitchdev/twitch-cli/issues/81
        #[cfg(not(feature = "mock_api"))]
        if _content != "application/json" {
            return Err(RequestParseError::NotJson {
                found: String::from_utf8_lossy(_content.as_bytes()).into_owned(),
            });
        }
    }
    serde_json::from_slice(body).map_err(Into::into)
}
/// Parses a response, validating it and returning json deserialized response
Parses a response, validating it and returning json deserialized response
Parses a response validating it and returning json deserialized response
pub(crate) fn parse_response<T: serde::de::DeserializeOwned>(
    resp: &HttpResponse,
) -> Result<T, RequestParseError> {
    let body = parse_token_response_raw(resp)?.body();
    if let Some(_content) = resp.headers().get(http::header::CONTENT_TYPE) {
        // TODO: Remove this cfg, see issue https://github.com/twitchdev/twitch-cli/issues/81
        #[cfg(not(feature = "mock_api"))]
        if _content != "application/json" {
            return Err(RequestParseError::NotJson {
                found: String::from_utf8_lossy(_content.as_bytes()).into_owned(),
            });
        }
    }
    serde_json::from_slice(body).map_err(Into::into)
}
pub ( crate ) fn parse_response < T : serde :: de :: DeserializeOwned > ( resp : & HttpResponse , ) -> Result < T , RequestParseError > { let body = parse_token_response_raw ( resp ) ? . body ( ) ; if let Some ( _content ) = resp . headers ( ) . get ( http :: header :: CONTENT_TYPE ) { // TODO: Remove this cfg, see issue https://github.com/twitchdev/twitch-cli/issues/81 # [ cfg ( not ( feature " " ) ) ] if _content != " " { return Err ( RequestParseError :: NotJson { found : String :: from_utf8_lossy ( _content . as_bytes ( ) ) . into_owned ( ) , } ) ; } } serde_json :: from_slice ( body ) . map_err ( Into :: into ) }
Parses a response, validating it and returning json deserialized response
Parses a response validating it and returning json deserialized response
resp
&HttpResponse