From 1f5072eaf75ee0f2af410bdef6853859e25412e3 Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Fri, 10 Nov 2023 09:48:25 +0100 Subject: [PATCH] spin: migrate to 2.0 Some minor API tweaks were needed. --- Cargo.toml | 2 +- src/spin.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f2fb7ca..b477c4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ base64 = "0.21.0" num-traits = "0.2.15" serde_json = "1.0.91" worker = { version = "0.0.18", optional = true } -spin-sdk = { version = "2.0", git = "https://github.com/fermyon/spin", tag = "v2.0.0", default-features = false, optional = true } +spin-sdk = { version = "2.0", git = "https://github.com/fermyon/spin", tag = "v2.0.0", default-features = false, features = ["http"], optional = true } sqlite3-parser = { version = "0.8.0", default-features = false, features = [ "YYNOERRORRECOVERY" ] } http = { version = "0.2", optional = true } bytes = { version = "1.4.0", optional = true } diff --git a/src/spin.rs b/src/spin.rs index e8f1f2a..941e514 100644 --- a/src/spin.rs +++ b/src/spin.rs @@ -22,10 +22,8 @@ impl HttpClient { .method("POST") .body(Some(bytes::Bytes::copy_from_slice(body.as_bytes())))?; - let response = spin_sdk::outbound_http::send_request(req); - let resp: String = - std::str::from_utf8(&response?.into_body().unwrap_or_default())?.to_string(); - let response: pipeline::ServerMsg = serde_json::from_str(&resp)?; + let response: http::Response = spin_sdk::http::send(req).await?; + let response: pipeline::ServerMsg = serde_json::from_str(&response.into_body())?; Ok(response) } }