package Shrlbe; use Mojo::Base 'Mojolicious', -signatures; use Shrlbe::Utils; my $SITE_NAME = 'shrl.be'; my $db_file = 'shrl.db'; # This method will run once at server start sub startup ($self) { # Load configuration from config file my $config = $self->plugin('NotYAMLConfig'); # Configure the application $self->secrets($config->{secrets}); my $utils = Shrlbe::Utils->new(); $self->helper(site_name => sub { return $SITE_NAME }); $self->helper(db_file => sub { return $db_file }); $self->helper(sh_utils => sub { return $utils }); # Router my $r = $self->routes; # Normal route to controller $r->get('/')->to('main#index'); $r->get('/s/*url')->to('main#short_api'); $r->post('/')->to('main#short'); $r->get('/:shorten_path')->to('main#get_shorten'); } 1;