Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the builtin Request/Response types #1939

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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