requires 'Catalyst::Runtime' => '5.80004';
requires 'List::MoreUtils';
+requires 'MooseX::Types::Structured';
+requires 'MooseX::Lexical::Types';
+
resources repository => 'git@github.com:bobtfish/catalyst-dynamicappdemo.git';
auto_install;
sub {
my ($self, $c, @args) = @_;
$c->res->header('X-From-Model', $model);
- $c->res->header('X-From-Model-Data', $c->model($model)->$method_name(@args));
+ my $response = $c->model($model)->$method_name($c->req->data);
+ $c->res->header('X-From-Model-Data', $response);
$c->res->body('OK');
+ $c->stash->{response} = $response;
};
}
package SomeModelClass;
use Moose;
use CatalystX::ControllerGeneratingModel;
+use DemoTypeLibrary qw/MessageDocument/;
+use MooseX::Lexical::Types qw/MessageDocument/;
use namespace::autoclean;
# Note trivial calling convention.
# Introspection should only reflect methods which satisfy the calling convention
# This is left as an exercise to the reader. :)
+# Note command syntax not actually needed, this could be a normal sub,
+# but doing so makes the eventual merge harder..
+
command say_hello => sub {
- my ($self, $name) = @_;
- return("Hello $name");
+ my ($self, $document) = @_;
+
+ my $name = $document->{name};
+ return({ type => 'say_hello_response',
+
+ body => "Hello $name" });
};
with 'SomeModelClassInterface';
+before 'say_hello' => sub {
+ my $self = shift;
+ my MessageDocument $message = shift;
+};
+
__PACKAGE__->meta->make_immutable;