MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / http_request

Method http_request

supervisor/client/src/lib.rs:90–108  ·  view source on GitHub ↗
(
        &self,
        method: &str,
        path: &str,
        body: B,
    )

Source from the content-addressed store, hash-verified

88 }
89
90 async fn http_request<T: serde::de::DeserializeOwned, B: serde::Serialize>(
91 &self,
92 method: &str,
93 path: &str,
94 body: B,
95 ) -> Result<T> {
96 let body_bytes = match method {
97 "POST" | "PUT" | "PATCH" => serde_json::to_vec(&body)?,
98 _ => vec![],
99 };
100 let (status, response_bytes) =
101 http_request(method, &self.base_url, path, &body_bytes).await?;
102 if status != 200 {
103 anyhow::bail!("Server returned error: {}", status);
104 }
105 let response: Response<T> =
106 serde_json::from_slice(&response_bytes).context("Failed to parse response")?;
107 response.into_result().context("Server returned error")
108 }
109
110 async fn http_get<T: serde::de::DeserializeOwned>(&self, path: &str) -> Result<T> {
111 self.http_request("GET", path, ()).await

Callers 7

http_getMethod · 0.80
deployMethod · 0.80
startMethod · 0.80
stopMethod · 0.80
removeMethod · 0.80
clearMethod · 0.80
shutdownMethod · 0.80

Calls 2

http_requestFunction · 0.85
into_resultMethod · 0.80

Tested by

no test coverage detected