1 package Catalyst::Plugin::SubRequest;
9 Catalyst::Plugin::SubRequest - Make subrequests to actions in Catalyst
13 use Catalyst 'SubRequest';
15 $c->subreq('/test/foo/bar', { template => 'magic.tt' });
19 Make subrequests to actions in Catalyst. Uses the catalyst
20 dispatcher, so it will work like an external url call.
26 =item subreq path, [stash as hash ref], [parameters as hash ref]
30 Takes a full path to a path you'd like to dispatch to. Any additional
31 parameters are put into the stash.
37 *subreq = \&sub_request;
40 my ( $c, $path, $stash, $params ) = @_;
43 local $c->{stash} = $stash || {};
44 local $c->res->{body} = undef;
45 local $c->req->{arguments} = $c->req->{arguments};
46 local $c->req->{action};
47 local $c->req->{path};
48 local $c->req->{parameters};
51 $c->req->params($params || {});
53 $c->log->debug("Subrequest to ${path}, action is ". $c->req->action )
55 # FIXME: Hack until proper patch in NEXT.
56 local $NEXT::NEXT{$c,'dispatch'};
67 Marcus Ramberg, C<mramberg@cpan.org>
71 SRI, for writing the awesome Catalyst framework
75 This program is free software, you can redistribute it and/or modify it under
76 the same terms as Perl itself.