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

enhancements for spring-webflux #25988

Closed
binggo-top opened this issue Oct 29, 2020 · 2 comments
Closed

enhancements for spring-webflux #25988

binggo-top opened this issue Oct 29, 2020 · 2 comments

Comments

@binggo-top
Copy link

binggo-top commented Oct 29, 2020

:
image

For enhancements, provide context and describe the problem.
context&problem:
When I use webclient to request an http address with optional request parameters, even if I pass a null value to the optional parameter, the null value will be changed to an empty string in the final request
image

image
Can webclient automatically recognize the request parameter that is null, and then not display it in the request address?
Means that when'org_team' is null, the last request address is'/api/list_sla_instances?bu=%E9%85%92%E5%BA%97%E6%97%85%E6%B8%B8&bg=%E9 %85%92%E5%BA%97&dateKey=2020-10-29'

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 29, 2020
@rstoyanchev
Copy link
Contributor

@binggo-top it is preferable to post text rather than images. It's easier to see the necessary detail and more search friendly.

So you have a URI template such as "/path?org_team={org_team}" and when expanding with an null or an empty Optional you want the query parameter to not appear at all.

It doesn't work like that because you already have org_team as a literal in the template. It is also possible and legitimate to have a parameter with an empty value so there is no way for the framework to know whether you want that or no parameter to appear at all.

In 5.3 there is a new queryParamIfPresent(Optional) method, based on #25951, so you could do:

webClient.get()
        .uri("/path", builder -> builder.queryParamIfPresent("org_team", orgTeamOptionalValue))

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Oct 29, 2020
@binggo-top
Copy link
Author

Thank you very much for your answers, I will try the method you mentioned above.

@rstoyanchev rstoyanchev removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 29, 2020
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

No branches or pull requests

3 participants