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 for route->via('get')
. via
is set up to restrict a route to particular methods (e.g. GET
or POST
or both). It might appear redundant, but consider how often you're likely to have a get()
route in your Mojolicious app...