Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Dancer2 parameters understanding and usage

by 1nickt (Canon)
on Nov 29, 2017 at 18:08 UTC ( [id://1204545]=note: print w/replies, xml ) Need Help??


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:

get '/foo/:name/bar/:age/:occupation' => sub { return '<pre>'.Dumper({ params }).'</pre>'; };
If the user requests the following URL:
http://localhost:5000/foo/Discipulus/bar/42/student?country=Eataly&cit +y=Roma
The app displays in the browser:
<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.)


The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1204545]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-16 17:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found