MCPcopy Create free account
hub / github.com/acking-you/static_flow / parse_admin_gpt2api_rs_response

Function parse_admin_gpt2api_rs_response

crates/frontend/src/api.rs:2552–2579  ·  view source on GitHub ↗
(response: gloo_net::http::Response)

Source from the content-addressed store, hash-verified

2550
2551#[cfg(not(feature = "mock"))]
2552async fn parse_admin_gpt2api_rs_response<T>(response: gloo_net::http::Response) -> Result<T, String>
2553where
2554 T: DeserializeOwned,
2555{
2556 if !response.ok() {
2557 let text = response.text().await.unwrap_or_default();
2558 return Err(format!("Failed: {text}"));
2559 }
2560 // Guard against SPA fallback returning index.html with a 200. Without this
2561 // check, `response.json()` on the HTML body surfaces as the cryptic
2562 // "Parse error: SerdeError(expected value)" banner. Surface a clearer
2563 // message so the operator knows the gpt2api-rs integration is missing on
2564 // the backend rather than chasing a phantom JSON bug.
2565 let content_type = response
2566 .headers()
2567 .get("content-type")
2568 .unwrap_or_default()
2569 .to_lowercase();
2570 if !content_type.contains("application/json") {
2571 return Err("gpt2api-rs admin endpoint is not available on this backend (got a non-JSON \
2572 response). Ensure the gpt2api-rs integration is enabled on the server build."
2573 .to_string());
2574 }
2575 response
2576 .json()
2577 .await
2578 .map_err(|e| format!("Parse error: {:?}", e))
2579}
2580
2581#[cfg(not(feature = "mock"))]
2582async fn get_admin_gpt2api_rs<T>(path: &str) -> Result<T, String>

Callers 6

get_admin_gpt2api_rsFunction · 0.85
post_admin_gpt2api_rsFunction · 0.85
delete_admin_gpt2api_rsFunction · 0.85
patch_admin_gpt2api_rsFunction · 0.85

Calls 2

okMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected