in reply to Re^2: Dancer2 parameters understanding and usage
in thread Dancer2 parameters understanding and usage
Just to be clear about route parameters. You can define any part of a URL path as a parameter. You don't need a 'static' part to prefix a param, although a lot of apps, particularly REST APIs, do that. You can also use route and query (and even body) params together. For example:
If the user requests the following URL:get '/foo/:name/bar/:age/:occupation' => sub { return '<pre>'.Dumper({ params }).'</pre>'; };
The app displays in the browser:http://localhost:5000/foo/Discipulus/bar/42/student?country=Eataly&cit +y=Roma
<pre>$VAR1 = { 'name' => 'Discipulus', 'age' => '42', 'city' => 'Roma', 'occupation' => 'student', 'country' => 'Eataly' }; </pre>
Also see: Dancer2 Advent Calendar: New Parameters Keywords. (The Dancer2 Advent Calendar is a great source of documentation and examples.)
|
|---|