--- /dev/null
+Revision history for Perl extension Catalyst::Plugin::Static.
+
+0.04 Sat Mar 19 20:27:00 2005
+ - Updated forward to cat5 style
+0.03 Sat Mar 19 20:27:00 2005
+ - Fixed documentation.
+0.02 Sat Feb 19 10:32:00 2005
+ - Ooops, missed MANIFEST
+
+0.01 Fri Mar 5 22:00:00 2005
+ - first release
--- /dev/null
+Changes
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+SubRequest.pm
+t/01use.t
+t/02subreq.t
+t/lib/TestApp.pm
--- /dev/null
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Catalyst-Plugin-SubRequest
+version: 0.04
+version_from: SubRequest.pm
+installdirs: site
+requires:
+ Catalyst: 2.99
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
--- /dev/null
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Catalyst::Plugin::SubRequest',
+ AUTHOR => 'Marcus Ramberg <marcus@thefeed.no>',
+ PREREQ_PM => {
+ Catalyst => '2.99',
+ },
+ VERSION_FROM => 'SubRequest.pm'
+);
--- /dev/null
+NAME
+ Catalyst::Plugin::Static - Serve static files with Catalyst
+
+SYNOPSIS
+ use Catalyst 'Static';
+
+ $c->serve_static;
+
+DESCRIPTION
+ Serve static files from config->{root}.
+
+ METHODS
+ serve_static
+SEE ALSO
+ Catalyst.
+
+AUTHOR
+ Sebastian Riedel, "sri@cpan.org"
+
+COPYRIGHT
+ This program is free software, you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
--- /dev/null
+package Catalyst::Plugin::SubRequest;
+
+use strict;
+
+our $VERSION = '0.04';
+
+
+=head1 NAME
+
+Catalyst::Plugin::SubRequest - Make subrequests to actions in Catalyst
+
+=head1 SYNOPSIS
+
+ use Catalyst 'SubRequest';
+
+ $c->subreq('!test','foo','bar');
+
+=head1 DESCRIPTION
+
+Make subrequests to actions in Catalyst.
+
+=head1 METHODS
+
+=over 4
+
+=item subreq action, args
+
+=item sub_request
+
+takes the name of the action you would like to call, as well as the
+arguments you want to pass to it.
+
+=back
+
+=cut
+
+*subreq = \&sub_request;
+
+sub sub_request {
+ my ( $c, $action, @args ) = @_;
+ my %old_req;
+ $old_req{stash} = $c->{stash};$c->{stash}={};
+ $old_req{content} = $c->res->output;$c->res->output(undef);
+ $old_req{args} = $c->req->arguments;$c->req->arguments([@args]);
+ $old_req{action} = $c->req->action;$c->req->action($action);
+ $c->dispatch();
+ my $output = $c->res->output;
+ $c->{stash} = $old_req{stash};
+ $c->res->output($old_req{content});
+ $c->req->arguments($old_req{args});
+ $c->req->action($old_req{action});
+ return $output;
+}
+
+=head1 SEE ALSO
+
+L<Catalyst>.
+
+=head1 AUTHOR
+
+Marcus Ramberg, C<mramberg@cpan.org>
+
+=head1 THANK YOU
+
+SRI, for writing the awesome Catalyst framework
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+1;
--- /dev/null
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok('Catalyst::Plugin::SubRequest') }
--- /dev/null
+package main;
+
+use Test::More tests => 6;
+use lib 't/lib';
+use Catalyst::Test 'TestApp';
+use File::stat;
+use File::Slurp;
+use HTTP::Date;
+
+my $stat = stat($0);
+
+{
+ ok( my $response = request('/normal'), 'Normal Request' );
+ is( $response->code, 200, 'OK status code' );
+ is( $response->content, '123', 'Normal request content', );
+}
+
+{
+ ok( my $response = request('/subreq'), 'Sub Request' );
+ is( $response->code, 200, 'OK status code' );
+ is( $response->content, '11233', 'Normal request content', );
+}
+
--- /dev/null
+package TestApp;
+
+use Catalyst qw[-Engine=Test SubRequest];
+
+__PACKAGE__->config(
+ name=>"subrequest test"
+);
+
+__PACKAGE__->setup();
+
+ sub begin : Private {
+ my ( $self, $c ) = @_;
+ $c->res->body($c->res->body().'1');
+ }
+
+ sub subreq : Global {
+ my ( $self, $c ) = @_;
+ $c->log->info("self is ". ref $self);
+ $c->log->info("Context is ". ref $c);
+ my $subreq= $c->res->body() .
+ $c->subreq('/normal');
+ $c->res->body($subreq);
+ }
+
+ sub normal : Global {
+ my ( $self, $c ) = @_;
+ $c->res->body($c->res->body().'2');
+ }
+
+ sub end : Private {
+ my ( $self, $c ) = @_;
+ $c->res->body($c->res->body().'3');
+ }
+
+
+1;