Skip to content

lambda_http::Request should expose a QueryMap from a raw_query_string #470

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

Closed
adriandelgado opened this issue May 5, 2022 · 3 comments · Fixed by #483
Closed

lambda_http::Request should expose a QueryMap from a raw_query_string #470

adriandelgado opened this issue May 5, 2022 · 3 comments · Fixed by #483

Comments

@adriandelgado
Copy link

This is a follow-up to this issue @calavera

I had a new idea while reading closely the Payload format Version 2.0. There is a rawQueryString field! This means we can use this field to correctly parse query parameters into a QueryMap.

The lambda_http crate already appends this raw_query_string into the Uri of the request (as seen in the function request::into_api_gateway_v2_request), and the wrong QueryStringParameters are put inside an extension of the request.

So my idea is... maybe we can also expose theraw_query_string in some way but already parsed into a QueryMap. Something like an extension that can be accessed through the RequestExt trait. My reasoning is that most people using API Gateway expect the QueryStringParameters to behave according to the whatwg spec.

Maybe we can put a warning about this weird quirk of AWS in the documentation of RequestExt::query_string_parameters and push devs to use a new method like raw_query_string.

@adriandelgado adriandelgado changed the title lambda_http::Request should expose raw_query_string as a QueryMap lambda_http::Request should expose a QueryMap from a raw_query_string May 5, 2022
@calavera
Copy link
Contributor

calavera commented May 6, 2022

what if we make the QueryStringParameters use the right parameters by creating a QueryMap from the raw_query_string, instead of the mangled apigw v2 ones? To be honest, I don't believe anyone would expect the current behavior of not parsing commas correctly.

@adriandelgado
Copy link
Author

That is much better in my opinion. The reason I didn't propose that is that technically the official behavior is to split at commas, but yes... no one expects that.

We should put a note in the documentation saying that we are not following the API Gateway Payload format Version 2.0 on purpose.

@calavera
Copy link
Contributor

calavera commented May 6, 2022

yeah, if someone needs the payload format version 2 behavior, they can use the raw runtime and receive those events specifically, they don't need to use lambda_http.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants