37 lines
969 B
Perl
37 lines
969 B
Perl
package MyApp;
|
|
use Mojo::Base 'Mojolicious', -signatures;
|
|
use MyApp::Model::FactoidDB;
|
|
use MyApp::Memcache;
|
|
|
|
has 'factdb';
|
|
has 'mcache';
|
|
|
|
# This method will run once at server start
|
|
sub startup ($self) {
|
|
|
|
# Load configuration from config file
|
|
my $config = $self->plugin('NotYAMLConfig');
|
|
|
|
my $dsn = $config->{dsn};
|
|
my $factdb = MyApp::Model::FactoidDB->new(dsn => $dsn);
|
|
$self->factdb($factdb);
|
|
|
|
my $mserver = $config->{memcache_server};
|
|
my $mcache = MyApp::Memcache->new(server => $mserver);
|
|
$self->mcache($mcache);
|
|
|
|
# Configure the application
|
|
$self->secrets($config->{secrets});
|
|
|
|
# Router
|
|
my $r = $self->routes;
|
|
|
|
# Normal route to controller
|
|
$r->get('/')->to('example#welcome');
|
|
$r->get('/*server/*names/list')->to('example#display');
|
|
$r->get('/*server/*names/search')->to('example#search');
|
|
$r->get('/*server/*names/revisions')->to('example#revisions');
|
|
$r->get('/*server/*names/autocomplete')->to('example#autocomplete');
|
|
}
|
|
|
|
1;
|