The GET parameters are the URL query string parameters. The Params addon creates JSON using the URL query string parameters. The method getFromUrl
allows you to specify a GET parameter or get all of the GET parameters. You can also use the alias url to get URL query string parameters.
For example, for the URL http://www.yahoo.com?foo=1&bar=2, the Params addon would create the following object:
The POST parameters come from the HTTP POST request body and often consist of form data. As with query string parameters, the Params addon has the
method getFromBody that allows you to specify a single parameter or get all of the POST body parameters.
The routing parameters are set in the routing configuration file routes.json. For each defined route, you can use the params property to set
routing parameters. Because routes.json allows you to specify mojit actions for different paths and HTTP methods, you can set routing parameters
based on the routing configuration.
For instance, in the routes.json below, the routing parameter coupon is true when a POST call is made on the /coupon/form, but when a
GET call is made on the same path, coupon is false. The coupon parameter could be used by the mojit controller to do something such as give
a coupon to a user posting information.
The Params addon also has the method getFromMerged that lets you get one or all of the GET, POST, and routing parameters. Because all of the
parameters are merged into one collection, one parameter might be overridden by another with the same key. You can also use the alias merged to
get one or all of the GET, POST, and routing parameters.
Thus, the parameter types are given the following priority:
For example, if each parameter type has a foo key, the foo routing parameter will override both the GET and POST foo parameters.
The method cookie.get(name) is used to get the cookie value associated with name. In the example controller below, the cookie value
for 'user' is obtained and then used to pass user information to the template.