I'm replacing an old PHP API with one implemented in Clojure. The API has an endpoint that accepts array style parameters, for example:
http://localhost/create?person[name]=John&person[gender]=m
PHP would yield this:
array(
"person" => array(
"name" => "John",
"gender" => "m"
)
)
We're currently using Ring's wrap-params to process the parameters. If you look at the source for ring's input decoding, you'll see that ring takes a simple view of decoding the input parameters - just split it on the & and =. It therefore yields the following:
{"person[name]" "John"
"person[gender]" "m"}
To be explicit, in Clojure, I'd want the following parameters:
{"person" {"name" "John"
"gender" "m"}}
How can I set up my ring app to properly accept the array style parameters supported by PHP? Is there any third party middleware I can use?
ring.middleware.nested-paramsseems to be the solution. Working on implementing it properly at the moment, documentation is a bit sparse. - Brad Koch