Skip to content

Instantly share code, notes, and snippets.

@preaction
Last active September 3, 2017 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save preaction/951888f6ebc61c2e000770297ef22d2c to your computer and use it in GitHub Desktop.
Save preaction/951888f6ebc61c2e000770297ef22d2c to your computer and use it in GitHub Desktop.
package TestApp;
use Mojo::Base 'Mojolicious';
sub startup {
my $app = shift;
$app->plugin('PODRenderer');
my $r = $app->routes;
$r->any('/svc')->to('Service#serv');
}
package TestApp::Controller::Service;
use Mojo::Base 'Mojolicious::Controller';
use Mod::Service;
sub serv {
my ( $c ) = @_;
my $svc = Mod::Service->new( app_name => $c->app->moniker );
$svc->s_start;
}
package Mod::Service;
use v5.14;
use utf8;
use Mojo::Base;
has app_name => 'default app name';
sub s_start {
my ( $self ) = @_;
$self->testme();
# other stuff
}
sub testme {
my ( $self ) = @_;
# stuff
say "Mod::Service->testme called";
say "My app name is " . $self->app_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment