lib/CrashTest.pm
changeset 78 0ebef32c34af
child 79 4ae8bb6f8a96
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/CrashTest.pm	Wed Nov 04 17:43:00 2015 +0100
@@ -0,0 +1,53 @@
+package CrashTest;
+use Mojo::Base 'Mojolicious';
+
+use CrashTest::Model::Storage;
+use CrashTest::Model::StackFilter;
+use CrashTest::Model::CrashReport;
+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->helper(crash_reports     => sub { state $crash_reports   = CrashTest::Model::CrashReport->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}->{Common}->{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('/report/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ])->to('crash_reports#report')->name('report');
+
+    $r->post('/submit')->to('crash_inserter#insert');
+}
+
+1;