Skip to content

Commit aa0a193

Browse files
committed
add collection query param method
1 parent 3ecc1bd commit aa0a193

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

http-client/src/main/java/io/avaje/http/client/HttpClientRequest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ public interface HttpClientRequest {
245245
*/
246246
HttpClientRequest queryParam(Map<String, ?> params);
247247

248+
/**
249+
* Add a query parameter with multiple values
250+
*
251+
* @param name The name of the query parameter
252+
* @param value The values of the query parameter which can be null
253+
* @return The request being built
254+
*/
255+
default HttpClientRequest queryParam(String name, Collection<String> values) {
256+
return queryParam(name, values);
257+
}
258+
248259
/**
249260
* Add a form parameter.
250261
*

http-client/src/test/java/io/avaje/http/client/HelloControllerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ void async_list_as() throws ExecutionException, InterruptedException {
801801
void get_withPathParamAndQueryParam_returningBean() {
802802

803803
final HelloDto dto = clientContext.request()
804-
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", null)
804+
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", (Object) null)
805805
.GET()
806806
.bean(HelloDto.class);
807807

@@ -813,7 +813,7 @@ void get_withPathParamAndQueryParam_returningBean() {
813813
@Test
814814
void callBean() {
815815
final HelloDto dto = clientContext.request()
816-
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", null)
816+
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", (Object) null)
817817
.GET()
818818
.call().bean(HelloDto.class).execute();
819819

@@ -825,7 +825,7 @@ void callBean() {
825825
@Test
826826
void callBeanAsync() throws ExecutionException, InterruptedException {
827827
final CompletableFuture<HelloDto> future = clientContext.request()
828-
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", null)
828+
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", (String) null)
829829
.GET()
830830
.call().bean(HelloDto.class).async();
831831

@@ -842,7 +842,7 @@ void async_whenComplete_returningBean() throws ExecutionException, InterruptedEx
842842
final AtomicReference<HelloDto> ref = new AtomicReference<>();
843843

844844
final CompletableFuture<HelloDto> future = clientContext.request()
845-
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", null)
845+
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", (String) null)
846846
.GET()
847847
.async().bean(HelloDto.class);
848848

@@ -872,7 +872,7 @@ void async_whenComplete_returningBeanWithHeaders() throws ExecutionException, In
872872
final AtomicReference<HttpResponse<HelloDto>> ref = new AtomicReference<>();
873873

874874
final CompletableFuture<HttpResponse<HelloDto>> future = clientContext.request()
875-
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", null)
875+
.path("hello/43/2020-03-05").queryParam("otherParam", "other").queryParam("foo", (String) null)
876876
.GET()
877877
.async().as(HelloDto.class);
878878

0 commit comments

Comments
 (0)