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

Support for HTTP GET map parameters #6072

Merged
merged 9 commits into from
Feb 21, 2025
Merged

Support for HTTP GET map parameters #6072

merged 9 commits into from
Feb 21, 2025

Conversation

kwondh5217
Copy link
Contributor

@kwondh5217 kwondh5217 commented Jan 19, 2025

Motivation:

This pull request addresses #6058

Currently, @Param cannot be mapped to a Map, but this change enables that functionality, allowing query parameters to be handled as a Map.

Modifications:

  • Introduced logic in AnnotatedValueResolver to detect when a parameter is of type Map and the @Param annotation has an unspecified value.
    • Future enhancements may include supporting the mapping of specific values to a Map when the @Param value is explicitly specified.
  • Added a new method ofQueryParamMap to handle the creation of an AnnotatedValueResolver for mapping all query parameters into a Map.
    • Query parameters are collected into a Map using the stream-based collector.
  • Updated the existing logic to ensure this behavior only applies when the @Param value is unspecified and the parameter type is Map.

Result:

Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI, @kwondh5217, thanks for the PR. 😉
Would you add an e2e test that verifies if this change works?

GET http://127.0.0.1:xxx/map?a=b&c=d

@Get("/map")
public HttpResponse map(@Params Map<String, Object> map) {...}

@kwondh5217
Copy link
Contributor Author

@minwoox Thanks for your comment!
I've added a test in AnnotatedServiceTest to verify that this change works.
Please take a look when you have time! 🙇

@minwoox minwoox added this to the 1.32.0 milestone Jan 21, 2025
Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically looks good. Left just nits. 👍

@kwondh5217
Copy link
Contributor Author

@minwoox !
I’ve made the requested changes. Please take a look when you have time. 🙏

@kwondh5217 kwondh5217 requested a review from minwoox February 5, 2025 01:39
Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @kwondh5217! 😄

@kwondh5217
Copy link
Contributor Author

@jrhee17 !
I have set up the IDE and reformatted all files. Thank you for your review!

Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
@minwoox minwoox merged commit b1a09d4 into line:main Feb 21, 2025
14 checks passed
@minwoox
Copy link
Contributor

minwoox commented Feb 21, 2025

Nice work, @kwondh5217! 👏 👏 👏

@kwondh5217
Copy link
Contributor Author

@minwoox Thanks! 😄
I'll submit another PR to support Map<String, List> for handling multi-value query parameters.
Looking forward to your feedback on that as well! 🚀

@minwoox
Copy link
Contributor

minwoox commented Feb 21, 2025

@kwondh5217 I can't wait to see that. 😆

@kwondh5217
Copy link
Contributor Author

Hi @minwoox ,
I've submitted a PR to support Map<String, List<?>> for handling multi-value query parameters.
When you have some time, could you take a look? 🙇‍♂️

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

Successfully merging this pull request may close these issues.

Support for HTTP GET map parameters?
4 participants