| 1 | package FirewallManager; | ||
| 2 | 0 | ▶ | use Mojo::Base 'Mojolicious'; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 3 | |||
| 4 | use 5.012; | ||
| 5 | use Data::Dumper; | ||
| 6 | use Mojo::Headers; | ||
| 7 | |||
| 8 | # This method will run once at server start | ||
| 9 | sub startup { | ||
| 10 | my $self = shift; | ||
| 11 | |||
| 12 | my $db_params = { | ||
| 13 | "dsn" => "DBI:MariaDB:database=eladmin", | ||
| 14 | "username" => "careline", | ||
| 15 | "password" => "Cisc0123", | ||
| 16 | #"options" => { mysql_enable_utf8 => 1 } | ||
| 17 | }; | ||
| 18 | |||
| 19 | my $headers = Mojo::Headers->new; | ||
| 20 | $headers->access_control_allow_origin; | ||
| 21 | # Load configuration from hash returned by config file | ||
| 22 | my $config = $self->plugin('Config'); | ||
| 23 | my $api_route = $self->plugin('Crud'); | ||
| 24 | $self->plugin( 'DBI', $db_params ); | ||
| 25 | $self->plugin( 'CORS' ); | ||
| 26 | |||
| 27 | #say Dumper keys %$self; | ||
| 28 | say Dumper $self->dbi; | ||
| 29 | |||
| 30 | # Configure the application | ||
| 31 | $self->secrets( $config->{secrets} ); | ||
| 32 | |||
| 33 | # Router | ||
| 34 | my $r = $self->routes; | ||
| 35 | $r->api_routes( { name => "Device" } ); | ||
| 36 | $r->api_routes( { name => "Firewall" } ); | ||
| 37 | |||
| 38 | #say Dumper $self->ua; | ||
| 39 | # Normal route to controller | ||
| 40 | #$r->get('/')->to('example#welcome'); | ||
| 41 | } | ||
| 42 | |||
| 43 | 1; | ||