Skip to content

Commit

Permalink
Merge pull request #1939 from fermyon/improve-builtin-request-response
Browse files Browse the repository at this point in the history
Improve the builtin Request/Response types
  • Loading branch information
rylev authored Oct 25, 2023
2 parents b14654d + b337273 commit 7a95022
Show file tree
Hide file tree
Showing 5 changed files with 434 additions and 58 deletions.
2 changes: 1 addition & 1 deletion examples/variables-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use spin_sdk::{
/// This endpoint returns the config value specified by key.
#[http_component]
fn get(req: Request) -> anyhow::Result<Response> {
if req.path_and_query.contains("dotenv") {
if req.path().contains("dotenv") {
let val = variables::get("dotenv").expect("Failed to acquire dotenv from spin.toml");
return Ok(Response::new(200, val));
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/rust/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub fn http_component(_attr: TokenStream, item: TokenStream) -> TokenStream {

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

0 comments on commit 7a95022

Please sign in to comment.