I'm trying to understand mojolicious routing a little better.
Can someone explain the difference between using something like
$r->route('/register')->via('get')->to('auth#register')
as opposed to
$r->get('/register')->to('auth#register')
or are they exactly the same?
Well spotted - they are the same.
get
is a shorthand forroute->via('get')
.via
is set up to restrict a route to particular methods (e.g.GET
orPOST
or both). It might appear redundant, but consider how often you're likely to have aget()
route in your Mojolicious app...