Closed nistvan86 closed 8 years ago
Now I create test method:
@app.Route("/id-test")
test(@app.QueryParam("id") ids) {
return ids.join("+");
}
Then I implement query:
/id-test?id=%5B123,2,3%5d
And result: List<int>
I didn't came up with this syntax on my own. Here are some examples for this argument usage from other libraries. I think this should be implemented the same way in Redstone.dart.
JAX-RS
@GET
@Path("/query")
public Response getUsers(
@QueryParam("from") int from,
@QueryParam("to") int to,
@QueryParam("orderBy") List<String> orderBy) {
return Response
.status(200)
.entity("getUsers is called, from : " + from + ", to : " + to
+ ", orderBy" + orderBy.toString()).build();
}
URI Pattern : users/query?from=100&to=200&orderBy=age&orderBy=name
Spring MVC
public String method(@RequestParam(value="phone") String[] phoneArray){
....
}
URI Pattern: phone=val1&phone=val2&phone=val3
Thanks for reporting this!
Currently, Redstone relies on the Uri class (from the Dart SDK), to parse the query string, and unfortunately, this class only supports one value per parameter. There is a issue concerning this limitation, but it seems it won't be solved in the near future.
However, I'll do some research to see if we can work around this issue somehow.
I'd be very interested in this functionality too. :thumbsup:
Sorry for taking so long to reply. I've implemented this feature on v0.6 (which I hope to publish on github soon). Although, this feature requires a breaking change, since the request object must provide the query parameters as a Map<String, List<String>>
, instead of Map<String, String>
, so I won't implement it in the current (v0.5) stable branch.
Thank you! :) Waiting for v0.6 then.
The first alpha release of Redstone v0.6 is available for test: https://github.com/luizmineo/redstone.dart/tree/v0.6
This doesn't seem to work properly.
I've just tried this, and it doesn't work:
I'm calling it like:
Please support this argument variant.