Warn
POD ERRORS here is normal because DBIx::POS::Template used.
Mojolicious::Plugin::RoutesAuthDBI::Install
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
NAME
Mojolicious::Plugin::RoutesAuthDBI::Install - is a Mojolicious::Controller for installation instructions.
DB DESIGN DIAGRAM
See https://github.com/mche/Mojolicious-Plugin-RoutesAuthDBI/blob/master/Diagram.svg
Manual
$ read -d '' CODE <<PERL; perl -e "$CODE" get /man
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/man')
->to('install#manual', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new()->start();
PERL
View schema (define the postgresql schema name)
$ read -d '' CODE <<PERL; perl -e "$CODE" get /schema/<name> #
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/schema/:schema')
->to('DB#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new()->start();
PERL
Apply schema (define the postgresql schema name)
$ read -d '' CODE <<PERL; perl -e "$CODE" get /schema/<name> 2>/dev/null | psql -d <dbname> #
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/schema/:schema')
->to('DB#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new()->start();
PERL
Sample app
$ read -d '' CODE <<PERL; perl -e "$CODE" get /app 2>/dev/null > test-app.pl
use Mojo::Base 'Mojolicious';
sub startup {
shift->routes->route('/app')
->to('install#test_app', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');
}
__PACKAGE__->new()->start();
PERL
use Mojo::Base 'Mojolicious';
use DBI;
has dbh => sub { DBI->connect("DBI:Pg:dbname=<dbname>;", "postgres", undef); };
sub startup {
my $app = shift;
# $app->plugin(Config =>{file => 'Config.pm'});
$app->plugin('RoutesAuthDBI',
dbh=>$app->dbh,
auth=>{current_user_fn=>'auth_user'},
# access=> {},
admin=>{prefix=>'myadmin', trust=>'fooobaaar',},
);
}
__PACKAGE__->new()->start();
--
Define DBI->connect(...) and some plugin options in test-app.pl
Check list of admin routes:
$ perl test-app.pl routes
Start app
$ perl test-app.pl daemon
Trust url for admin-user creation:
$ perl test-app.pl get /<pluginconf->{admin}{prefix}>/<pluginconf->{admin}{trust}>/user/new/<new admin login>/<admin pass> 2>/dev/null
User will be created and assigned to role 'Admin' . Role 'Admin' assigned to namespace 'Mojolicious::Plugin::RoutesAuthDBI' that has access to all admin controller routes!
Sign in on browser
http://127.0.0.1:3000/sign/in/<new admin login>/<admin pass>
Administration of system ready!
3 POD Errors
The following errors were encountered while parsing the POD:
- Around line 74:
Unknown directive: =name
- Around line 76:
Unknown directive: =desc
- Around line 95:
Unknown directive: =sql