package CrashTest;
use Mojo::Base 'Mojolicious';
use CrashTest::Model::Storage;
use CrashTest::Model::StackFilter;
use CrashTest::Model::CrashReport;
use CrashTest::Model::CrashGroup;
use CrashTest::Model::CrashProcessor;
# This method will run once at server start
sub startup {
my $self = shift;
$self->secrets([
'My secret passphrase here'
]);
# External plugins
$self->plugin('Config');
$self->plugin('bootstrap_pagination');
# Documentation browser under "/perldoc"
#$self->plugin('PODRenderer');
# Commands
push @{$self->commands->namespaces}, 'CrashTest::Command';
# Helpers
$self->plugin("CrashTest::Helper::DateTime");
$self->plugin("CrashTest::Helper::Backtrace");
$self->plugin("CrashTest::Helper::XmlEscape");
$self->plugin("CrashTest::Helper::Stats");
$self->helper(crash_reports => sub { state $crash_reports = CrashTest::Model::CrashReport->new (app => $self); });
$self->helper(crash_groups => sub { state $crash_groups = CrashTest::Model::CrashGroup->new (app => $self); });
$self->helper(crash_processor => sub { state $crash_processor = CrashTest::Model::CrashProcessor->new (app => $self, config => $self->config); });
$self->helper(stackfilter => sub { state $crash_reports = CrashTest::Model::StackFilter->new (app => $self, config => $self->config); });
$self->helper(storage => sub { state $storage = CrashTest::Model::Storage->new (app => $self, config => $self->config); });
$self->plugin('Minion', $self->config->{Processor}->{JobQueue}->{Backend}->{Minion});
$self->storage->load_plugins();
$self->crash_processor->load_plugins();
# Router
my $r = $self->routes;
# Normal route to controller
$r->get('/')->to('crash_reports#index')->name('index');
$r->get('/reports')->to('crash_reports#index')->name('reports');
$r->get('/groups')->to('crash_groups#index')->name('groups');
$r->get('/groups/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ])->to('crash_groups#show')->name('group');
$r->get('/report/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ])->to('crash_reports#show')->name('report');
$r->post('/submit')->to('crash_inserter#insert');
}
1;