MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / response_to_json

Function response_to_json

tests/common/mod.rs:491–502  ·  view source on GitHub ↗
(mut response: ureq::http::Response<ureq::Body>)

Source from the content-addressed store, hash-verified

489}
490
491pub fn response_to_json(mut response: ureq::http::Response<ureq::Body>) -> (u16, Value) {
492 let status = response.status().as_u16();
493 let body = match response.body_mut().read_to_string() {
494 Ok(body) => body,
495 Err(err) => panic!("failed to read response body: {err}"),
496 };
497 let parsed = match serde_json::from_str::<Value>(&body) {
498 Ok(value) => value,
499 Err(err) => panic!("failed to decode JSON body `{body}`: {err}"),
500 };
501 (status, parsed)
502}
503
504/// True when a `ureq` error is a connection-level failure that a freshly
505/// started (or briefly overloaded) server can transiently raise before it is

Callers 6

post_jsonFunction · 0.85
post_json_bodyFunction · 0.85
patch_json_bodyFunction · 0.85
delete_jsonFunction · 0.85
post_jsonFunction · 0.85
get_jsonFunction · 0.85

Calls 1

statusMethod · 0.80

Tested by

no test coverage detected