Ado
view release on metacpan or search on metacpan
etc/plugins/routes.conf view on Meta::CPAN
to => {
#Ado::Control::Default
controller => 'Default',
action => 'index'
}
},
{ route => '/:controller/:action/:id',
params => {controller => qr/[\w-]{3,}/, action => qr/\w{3,}/, id => qr/\d+/},
via => [qw(GET PUT DELETE OPTIONS)],
to => {
#Ado::Control::Default
controller => 'Default',
action => 'form'
}
},
# This route will not be considered at all
{'index' => undef},
lib/Ado/Command/generate/crud.pm view on Meta::CPAN
{ route => "/$route/read/:id",
via => [qw(GET)],
to => "$route#read",
},
{ route => "/$route/create",
via => [qw(GET POST)],
to => "$route#create",
over => {authenticated => 1},
},
{ route => "/$route/update/:id",
via => [qw(GET PUT)],
to => "$route#update",
over => {authenticated => 1},
},
{ route => "/$route/delete/:id",
via => [qw(GET DELETE)],
to => "$route#delete",
over => {authenticated => 1},
};
}
return $_[0]->{routes};
lib/Ado/Plugin/Auth.pm view on Meta::CPAN
$app->routes->route('/ado-users/:action', over => {authenticated=>1});
$app->routes->route('/ado-users/:action',
over => [authenticated => 1, ingroup => 'admin']
);
#in etc/ado.$mode.conf or etc/plugins/foo.$mode.conf
routes => [
#...
{
route => '/ado-users/:action:id',
via => [qw(PUT DELETE)],
# only authenticated users can edit and delete users,
# and only if they are authorized to do so
over => [authenticated => 1, ingroup => 'admin'],
to =>'ado-users#edit'
}
],
=head2 ingroup
lib/Ado/Plugin/I18n.pm view on Meta::CPAN
action => qr/\w{3,}/
},
to => {
#Ado::Control::Default
controller => 'Default',
action => 'index'
}
},
{ route => '/:language/:controller/:action/:id',
via => [qw(GET PUT DELETE OPTIONS)],
params => {
$$config{language_param} => qr/(?:$l)/,
controller => qr/[\w-]{3,}/,
action => qr/\w{3,}/,
id => qr/\d+/
},
to => {
#Ado::Control::Default
controller => 'Default',
lib/Ado/Plugin/I18n.pm view on Meta::CPAN
...
}
This is the first option that will be checked if enabled.
The plugin prepares a default set of routes containing information
about the language.
/:language GET,OPTIONS
/:language/:controller GET,OPTIONS
/:language/:controller/:action GET,POST,OPTIONS
/:language/:controller/:action/:id GET,PUT,DELETE,OPTIONS
The language will be detected from current routes eg. C</bg/news/read/1234>
and put into the stash. Default value is 1.
=head2 language_from_host
{
language_from_host => 1,
language_from_route => 1,
...
lib/Ado/Plugin/I18n.pm view on Meta::CPAN
defined in the plugin configuration. Called in L</register>.
To create your own routes just create C<etc/plugin/i18n.conf> and add them to it.
They will replace the default routes.
#default routes including language placeholder.
$app->load_routes($self->routes);
/:language GET,OPTIONS
/:language/:controller GET,OPTIONS
/:language/:controller/:action GET,POST,OPTIONS
/:language/:controller/:action/:id GET,PUT,DELETE,OPTIONS
=head2 language
This is the underlying subroutine used in C<around_action> hook and c<language>
helper.
#Add helpers
$app->helper(language => \&language);
=head2 around_action
t/plugin/i18n-00.t view on Meta::CPAN
action => qr/\w{3,}/
},
to => {
#Ado::Control::Default
controller => 'Default',
action => 'index'
}
},
{ route => '/:language/:controller/:action/:id',
via => [qw(GET PUT DELETE OPTIONS)],
params => {
$$config{language_param} => qr/(?:$l)/,
controller => qr/[\w-]{3,}/,
action => qr/\w{3,}/,
id => qr/\d+/
},
to => {
#Ado::Control::Default
controller => 'Default',
t/plugin/routes.t view on Meta::CPAN
is($app->plugins()->namespaces->[1], 'Ado::Plugin', 'Ado::Plugin namespace is present');
#etc/plugin/routes.conf file is loaded and routes described in the file are present
my $rs = $app->routes;
my $c = Ado::Control->new;
my $m = Mojolicious::Routes::Match->new(root => $rs);
$m->find($c => {method => 'GET', path => '/'});
is $m->path_for->{path}, '/', 'right GET path: /';
is_deeply($m->stack->[0], {controller => 'Default', action => 'index'}, 'default#index ok');
$m->find($c => {method => 'PUT', path => '/default/form/1'});
is $m->path_for->{path}, '/default/form/1', 'right PUT path: /default/form/1';
is_deeply($m->stack->[0], {controller => 'default', action => 'form', id => 1},
'default#form ok');
$m->find($c => {method => 'POST', path => '/default'});
is $m->path_for->{path}, '/default', 'right POST path: /default';
is_deeply($m->stack->[0], {controller => 'default', action => 'index'}, 'default#form ok');
is $app->routes->lookup('perldocmodule')->to->{module}, 'Ado/Manual',
'"/perldoc" :module is "Ado/Manual".';
( run in 0.411 second using v1.01-cache-2.11-cpan-4e96b696675 )