lib/CrashTest.pm
changeset 78 0ebef32c34af
child 79 4ae8bb6f8a96
equal deleted inserted replaced
77:e408da1419cd 78:0ebef32c34af
       
     1 package CrashTest;
       
     2 use Mojo::Base 'Mojolicious';
       
     3 
       
     4 use CrashTest::Model::Storage;
       
     5 use CrashTest::Model::StackFilter;
       
     6 use CrashTest::Model::CrashReport;
       
     7 use CrashTest::Model::CrashProcessor;
       
     8 
       
     9 # This method will run once at server start
       
    10 sub startup {
       
    11     my $self = shift;
       
    12 
       
    13     $self->secrets([
       
    14         'My secret passphrase here'
       
    15     ]);
       
    16 
       
    17     # External plugins
       
    18     $self->plugin('Config');
       
    19     $self->plugin('bootstrap_pagination');
       
    20     # Documentation browser under "/perldoc"
       
    21     #$self->plugin('PODRenderer');
       
    22 
       
    23     # Commands
       
    24     push @{$self->commands->namespaces}, 'CrashTest::Command';
       
    25 
       
    26     # Helpers
       
    27     $self->plugin("CrashTest::Helper::DateTime");
       
    28     $self->plugin("CrashTest::Helper::Backtrace");
       
    29     $self->plugin("CrashTest::Helper::XmlEscape");
       
    30 
       
    31 
       
    32     $self->helper(crash_reports     => sub { state $crash_reports   = CrashTest::Model::CrashReport->new    (app => $self); });
       
    33 
       
    34     $self->helper(crash_processor   => sub { state $crash_processor = CrashTest::Model::CrashProcessor->new (app => $self, config => $self->config); });
       
    35     $self->helper(stackfilter       => sub { state $crash_reports   = CrashTest::Model::StackFilter->new    (app => $self, config => $self->config); });
       
    36     $self->helper(storage           => sub { state $storage         = CrashTest::Model::Storage->new        (app => $self, config => $self->config); });
       
    37 
       
    38     $self->plugin('Minion', $self->config->{Processor}->{Common}->{JobQueue}->{Backend}->{Minion});
       
    39 
       
    40     $self->storage->load_plugins();
       
    41     $self->crash_processor->load_plugins();
       
    42 
       
    43     # Router
       
    44     my $r = $self->routes;
       
    45 
       
    46     # Normal route to controller
       
    47     $r->get('/')->to('crash_reports#index')->name('index');
       
    48     $r->get('/report/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ])->to('crash_reports#report')->name('report');
       
    49 
       
    50     $r->post('/submit')->to('crash_inserter#insert');
       
    51 }
       
    52 
       
    53 1;