package LDV; use strict; use warnings; use utf8; use Mojo::Base 'Mojolicious'; sub startup { my ($self) = @_; $self->plugin(I18N => {default => 'ru'}); my $config = $self->app->home->rel_file('conf/ldv.conf'); $self->plugin(Config => {file => $config}); $self->app->mode('production'); $self->app->secret($self->app->config->{secret}); my $r = $self->routes; # /user my $user = $r->route('/user') -> to(controller => 'user'); $user->get('/') ->to(cb => sub { shift->redirect_to('/user/login'); }); $user->get('/login') ->to(action => 'login'); $user->get('/register') ->to(action => 'register'); $user->get('/profile') ->to(action => 'profile'); $user->post('/auth') ->to(action => 'auth'); $user->get ('/logout') ->to(action => 'logout'); $user->post('/create') ->to(action => 'create'); $user->post('/update') ->to(action => 'update'); $self->app->attr(ldap => sub { require LDV::LDAP; my $ldap = LDV::LDAP->new($self->app->config->{ldap}); return $ldap; }); # /zerobin my $zb = $r->route('/zerobin2') -> to(controller => 'zerobin'); $zb->post('/') -> to(action => 'save'); $zb->get ('/') -> to(action => 'create'); $zb->route('/:time', time => qr/\d+/) ->via('GET') -> to(action => 'view'); my $root = $self->app->config->{zerobin}->{root}; mkdir $self->app->home->rel_dir($root); } 1;