drogon
drogon copied to clipboard
getParameters
when using req->getParameters(),I can not get the paramter of same key,for example,url is:/api/list?key="hello"&key="world" when I call req->getParameters().equal_range("key") it only display the result value key="world" and ignore the fist value "hello"
As the parsing of query parameters is not defined in any RFC, the behavior is to be defined by the framework. I would say that in this case the described behavior is also what is to be expected.
There are some frameworks like PHP which support serialization of parameters with same names, but this is by no means a standard.
I think it makes sense to stay here somewhat with the RFC which only talks about unique parameters in the context of forms, and also apply it to query parameters.
Do you have any specific use cases where you rely on this implicit query parameter parsing behavior besides the “Hello, world!” example? Maybe there is another elegant solution.
req->getQuery() , get the full query string, and parse whatever you want.
+1 from me. It'd be very useful if Drogon could properly handle arrays of parameters. It's not part of the RFC but it is industry standard for many years.