HTTP parameter parsing
Ringo enhances the basic JSGI request to add advanced HTTP parameter parsing. To use this functionality, you need to invoke the Request function from module ringo/webapp/request with the JSGI request as argument.
If you are using ringo/webapp as request dispatcher, its handleRequest function will do this for you. Otherwise, you have to do it yourself.
require("ringo/webapp/request").Request(request);
This will add, among other things, properties called params, postParams, and queryParams to the request object. These are objects that are created on demand and populated with the parsed HTTP parameters.
The params object is a merged view of parameters sent with the query string and the request body, and both types of parameters can be accessed separately using the queryParams and postParams properties, respectively.
Parameters can be grouped as objects and arrays using square bracket notation for the parameter names. For example, the query string ?foo[bar]=1&foo[baz]=2 will result in the following parsed parameter value:
{foo: {bar: "1", baz: "2"}}
Using empty square brackets will result in an array. For instance, ?foo[]=1&foo[]=2 is parsed as:
{foo: ["1", "2"]}
These groupings can be nested arbitrarily. They also work for HTTP file upload, which Ringo supports out of the box.
