how to parse query argument using vertx?

nocturnal picture nocturnal · Oct 14, 2016 · Viewed 11.3k times · Source

I wanted to check if we can use getparam to parse start_time and end_time from the below request URL

https://[--hostname--]/sample_app/apthroughput/getAllControllers?start_time=<start time value>&end_time=<end time value>&label=<selected label>

Answer

Orkun Ozen picture Orkun Ozen · Aug 6, 2018

The parsing of a query string is quite straightforward except for when there are multiple values for the same query param.

e.g.: https://[--hostname--]/sample_app/apthroughput/getAllControllers?type=xxx&type=yyy

in such cases the code below helps getting all the params of a kind in List<String>

This answer gives an idea. Copying from it:

HttpServerRequest request = RoutingContext.request();
MultiMap params =  request.params();
List<String> param = params.getAll("personId");
Here you can get list of personId. URI be like

localhost:8081/myApi?personId=1&personId=2&personId=3