1 package Catalyst::Plugin::SubRequest;
10 Catalyst::Plugin::SubRequest - Make subrequests to actions in Catalyst
14 use Catalyst 'SubRequest';
16 $c->subreq('/test/foo/bar', { template => 'magic.tt' });
20 Make subrequests to actions in Catalyst. Uses the catalyst
21 dispatcher, so it will work like an external url call.
27 =item subreq path, [stash as hash ref], [parameters as hash ref]
31 Takes a full path to a path you'd like to dispatch to. Any additional
32 parameters are put into the stash.
38 *subreq = \&sub_request;
40 use Data::Dumper qw/Dumper/;
42 my ( $c, $path, $stash, $params ) = @_;
45 local $c->{stash} = $stash || {};
46 local $c->res->{output} = undef;
47 local $c->req->{arguments} = $c->req->{arguments};
48 local $c->req->{action};
49 local $c->req->{path};
50 local $c->req->{params};
53 $c->req->params($params || {});
55 $c->log->debug("Subrequest to $path , action is ". $c->req->action )
57 # FIXME: Hack until proper patch in NEXT.
58 local $NEXT::NEXT{$c,'dispatch'};
60 return $c->res->output;
69 Marcus Ramberg, C<mramberg@cpan.org>
73 SRI, for writing the awesome Catalyst framework
77 This program is free software, you can redistribute it and/or modify it under
78 the same terms as Perl itself.