Closed 0mars closed 2 years ago
Hi,
It's working as expected for me. Did you use get_param
instead of get_param_as_list
? As documented returns a single value
Here an example:
import falcon
class F:
def on_get(self, req: falcon.Request, res: falcon.Response):
res.media = {
'params': req.params,
'get_param': req.get_param('benefits[]'),
'get_param_as_list': req.get_param_as_list('benefits[]')
}
app = falcon.App()
app.add_route('/route', F())
>>> xh ":8080/route?q=&district=Lighthouse&offset=0&pricefrom=0&priceto=10000000&renttype=weekly&limit=10&bedrooms=1&benefits[]=wifi&benefits[]=ac"
HTTP/1.1 200 OK
Content-Length: 243
Content-Type: application/json
Date: Sat, 14 May 2022 08:31:56 GMT
Server: waitress
{
"params": {
"q": "",
"district": "Lighthouse",
"offset": "0",
"pricefrom": "0",
"priceto": "10000000",
"renttype": "weekly",
"limit": "10",
"bedrooms": "1",
"benefits[]": [
"wifi",
"ac"
]
},
"get_param": "ac",
"get_param_as_list": [
"wifi",
"ac"
]
}
Closing this since we cannot see any issue in the framework apart from the fact that Falcon doesn't treat the trailing []
in a parameter name in any special way. Although I've seen this []
in some APIs, but I think it's more common, or at least as common, to simply write ?benefits=wifi&benefits=ac
(i.e., without the []
). Furthermore, as @CaselIT demonstrated above, handling this []
should be fairly straightforward in your app's logic.
example url:
it reads the argument as benefits[] = 'ac'
but it should be a list of values instead
req.params['benefits'] = None