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. Uses the private name of
21 the action for dispatch.
27 =item subreq action, args
31 Takes a full path to a path you'd like to dispatch to.
37 *subreq = \&sub_request;
40 my ( $c, $path ) = @_;
43 $old_req{stash} = $c->{stash};$c->{stash}={};
44 $old_req{content} = $c->res->output;$c->res->output(undef);
45 $old_req{args} = $c->req->arguments;
46 $old_req{action} = $c->req->action;$c->req->action(undef);
47 $old_req{path} = $c->req->path;$c->req->path($path);
49 $c->log->debug("Subrequest to $path , action is ".
53 my $output = $c->res->output;
54 $c->{stash} = $old_req{stash};
55 $c->res->output($old_req{content});
56 $c->req->arguments($old_req{args});
57 $c->req->action($old_req{action});
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.