Skip to content

Commit 7a95022

Browse files
authored
Merge pull request #1939 from fermyon/improve-builtin-request-response
Improve the builtin Request/Response types
2 parents b14654d + b337273 commit 7a95022

File tree

5 files changed

+434
-58
lines changed

5 files changed

+434
-58
lines changed

examples/variables-rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use spin_sdk::{
66
/// This endpoint returns the config value specified by key.
77
#[http_component]
88
fn get(req: Request) -> anyhow::Result<Response> {
9-
if req.path_and_query.contains("dotenv") {
9+
if req.path().contains("dotenv") {
1010
let val = variables::get("dotenv").expect("Failed to acquire dotenv from spin.toml");
1111
return Ok(Response::new(200, val));
1212
}

sdk/rust/macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub fn http_component(_attr: TokenStream, item: TokenStream) -> TokenStream {
112112

113113
async fn handle_response<R: ::spin_sdk::http::IntoResponse>(response_out: ::spin_sdk::http::ResponseOutparam, resp: R) {
114114
let mut response = ::spin_sdk::http::IntoResponse::into_response(resp);
115-
let body = std::mem::take(&mut response.body);
115+
let body = std::mem::take(response.body_mut());
116116
let response = ::std::convert::Into::into(response);
117117
if let Err(e) = ::spin_sdk::http::ResponseOutparam::set_with_body(response_out, response, body).await {
118118
eprintln!("Could not set `ResponseOutparam`: {e}");

0 commit comments

Comments
 (0)