use Moose;
BEGIN { extends 'Catalyst::Controller::MessageDriven' }
- sub some_action : Local {
+ sub some_action : Local {
my ($self, $c) = @_;
# Reply with a minimal response message
my $response = { type => 'testaction_response' };
A Catalyst controller base class for use with Catalyst::Engine::Stomp,
which handles YAML-serialized messages. A top-level "type" key in the
-YAML determines the action dispatched to.
+YAML determines the action dispatched to.
=cut
__PACKAGE__->config(
- 'default' => 'text/x-yaml',
- 'stash_key' => 'response',
- 'map' => { 'text/x-yaml' => 'YAML' },
- );
+ 'default' => 'text/x-yaml',
+ 'stash_key' => 'response',
+ 'map' => { 'text/x-yaml' => 'YAML' },
+ );
sub begin :ActionClass('Deserialize') { }
sub end :ActionClass('Serialize') {
- my ($self, $c) = @_;
-
- # Engine will send our reply based on the value of this header.
- $c->response->headers->header( 'X-Reply-Address' => $c->req->data->{reply_to} );
-
- # Custom error handler - steal errors from catalyst and dump them into
- # the stash, to get them serialized out as the reply.
- if (scalar @{$c->error}) {
- my $error = join "\n", @{$c->error};
- $c->stash->{response} = { status => 'ERROR', error => $error };
- $c->error(0); # clear errors, so our response isn't clobbered
- }
+ my ($self, $c) = @_;
+
+ # Engine will send our reply based on the value of this header.
+ $c->response->headers->header( 'X-Reply-Address' => $c->req->data->{reply_to} );
+
+ # Custom error handler - steal errors from catalyst and dump them into
+ # the stash, to get them serialized out as the reply.
+ if (scalar @{$c->error}) {
+ my $error = join "\n", @{$c->error};
+ $c->stash->{response} = { status => 'ERROR', error => $error };
+ $c->error(0); # clear errors, so our response isn't clobbered
+ }
}
sub default : Private {
- my ($self, $c) = @_;
-
- # Forward the request to the appropriate action, based on the
- # message type.
- my $action = $c->req->data->{type};
- $c->forward($action, [$c->req->data]);
+ my ($self, $c) = @_;
+
+ # Forward the request to the appropriate action, based on the
+ # message type.
+ my $action = $c->req->data->{type};
+ $c->forward($action, [$c->req->data]);
}
__PACKAGE__->meta->make_immutable;
# The default serialization is YAML, but this configuration
# may be overridden in your controller:
__PACKAGE__->config(
- 'default' => 'text/x-yaml',
- 'stash_key' => 'rest',
- 'map' => { 'text/x-yaml' => 'YAML' },
- );
+ 'default' => 'text/x-yaml',
+ 'stash_key' => 'rest',
+ 'map' => { 'text/x-yaml' => 'YAML' },
+ );
=head1 DESCRIPTION
# subscribe, with client ack.
foreach my $queue (@queues) {
- my $queue_name = "/queue/$queue";
- $self->connection->subscribe({
- destination => $queue_name,
- ack => 'client',
- });
+ my $queue_name = "/queue/$queue";
+ $self->connection->subscribe({
+ destination => $queue_name,
+ ack => 'client',
+ });
}
# enter loop...
while (1) {
- my $frame = $self->connection->receive_frame();
- $self->handle_stomp_frame($app, $frame);
- last if $ENV{ENGINE_ONESHOT};
+ my $frame = $self->connection->receive_frame();
+ $self->handle_stomp_frame($app, $frame);
+ last if $ENV{ENGINE_ONESHOT};
}
exit 0;
}
my ($self, $c) = @_;
my $error = join "\n", @{$c->error};
if ($error) {
- $c->log->debug($error);
+ $c->log->debug($error);
}
return $self->next::method($c);
}
my $command = $frame->command();
if ($command eq 'MESSAGE') {
- $self->handle_stomp_message($app, $frame);
+ $self->handle_stomp_message($app, $frame);
}
elsif ($command eq 'ERROR') {
- $self->handle_stomp_error($app, $frame);
+ $self->handle_stomp_error($app, $frame);
}
else {
- $app->log->debug("Got unknown Stomp command: $command");
+ $app->log->debug("Got unknown Stomp command: $command");
}
}
--- /dev/null
+use strict;
+use warnings;
+
+use File::Spec;
+use Test::More;
+
+if ( !-e "inc/.author" ) {
+ plan skip_all => 'NoTabs test only for developers.';
+}
+else {
+ eval { require Test::NoTabs };
+ if ( $@ ) {
+ plan tests => 1;
+ fail( 'You must install Test::NoTabs to run 01_no_tabs.t' );
+ exit;
+ }
+}
+
+Test::NoTabs->import;
+all_perl_files_ok(qw/lib/);
--- /dev/null
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD} || -e 'inc/.author';
+
+all_pod_files_ok();
--- /dev/null
+use Test::More;
+
+eval "use Pod::Coverage 0.19";
+plan skip_all => 'Pod::Coverage 0.19 required' if $@;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD} || -e 'inc/.author';
+
+all_pod_coverage_ok(
+ {
+ also_private => [qw/BUILD BUILDARGS/]
+ }
+);