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');
20 Make subrequests to actions in Catalyst.
26 =item subreq action, args
30 takes the name of the action you would like to call, as well as the
31 arguments you want to pass to it.
37 *subreq = \&sub_request;
40 my ( $c, $action, @args ) = @_;
42 $old_req{stash} = $c->{stash};$c->{stash}={};
43 $old_req{content} = $c->res->output;$c->res->output(undef);
44 $old_req{args} = $c->req->arguments;$c->req->arguments([@args]);
45 $old_req{action} = $c->req->action;$c->req->action($action);
47 my $output = $c->res->output;
48 $c->{stash} = $old_req{stash};
49 $c->res->output($old_req{content});
50 $c->req->arguments($old_req{args});
51 $c->req->action($old_req{action});
61 Marcus Ramberg, C<mramberg@cpan.org>
65 SRI, for writing the awesome Catalyst framework
69 This program is free software, you can redistribute it and/or modify it under
70 the same terms as Perl itself.