Open racinmat opened 3 years ago
There is a WIP PR for this here: https://github.com/JuliaWeb/HTTP.jl/pull/433 (just need to decide the return type in case of multiple identical keys).
This issue has just bit me while using Oxygen.jl. Any progress on this?
If anyone is coming here looking for a hacky solution, I used this workaround
function queryparamdict(req::HTTP.Request)
d = Dict{String,Any}()
params = queryparampairs(URI(req.target))
for (key,value) in params
if key ∈ keys(d)
d[key] = [d[key]; value]
else
d[key] = value
end
end
return d
end
Representing an array in query parameter is tricky and there is no single true way, but I think at least one of the often-used approaches should be supported. Current behavior is:
I would expect all of them, or at least the ones with repeated
foo
to return an array instead of string with single value. It would make the type-stability more complicated, because now it'sDict{String,String}
, so accommodating arrays there would mean changing it probably toDict{String,Union{Vector},String}}
? I'm not sure how the proper solution should look like, but we should not definitely lose parameters as the current behavior does.