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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

kwondh5217
Copy link

@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:

Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
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) {...}

Signed-off-by: Daeho Kwon <trewq231@naver.com>
@kwondh5217
Copy link
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! 🙇

Signed-off-by: Daeho Kwon <trewq231@naver.com>
@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. 👍

Signed-off-by: Daeho Kwon <trewq231@naver.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
@kwondh5217
Copy link
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 and others added 4 commits February 5, 2025 11:48
Co-authored-by: minux <songmw725@gmail.com>
Signed-off-by: Daeho Kwon <trewq231@naver.com>
# Conflicts:
#	core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedValueResolver.java
Signed-off-by: Daeho Kwon <trewq231@naver.com>
@kwondh5217
Copy link
Author

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

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?
3 participants