Hulk, An action dispatcher.
To write your own action:
package Hulk::Do::StopService;
use warnings;
use strict;
use Any::Moose;
extends qw(Hulk::Do);
# optional (this uses gfx's Data::Validator)
sub schema {
uri => { isa => 'Str', xor => [qw(schema host path_query)] },
schema => { isa => 'Str', default => 'http' },
host => { isa => 'Str', default => '127.0.0.1' },
path_query => { isa => 'Str', default => '/' },
method => { isa => 'Str', default => 'GET' },
}
sub run {
my $self = shift;
my $args = $self->args;
my $id = $args->{id};
return $self->error( "Serivce id required." ) unless $id;
# ... do something
...
# ... do other stuff
my $ret = $self->also_do( 'StopOtherService' , { arg1 => ... , arg2 => ... } );
return $self->success( "Service stopped." );
}
1;
Declarative way:
use Hulk::Declare;
mount 'TwitterAPI' under '/__api/';
when '/..../' => sub {
};
when '/.....' => sub {
};
1;
- use Data::Validator.
- Integrate with Path::Dispatcher.