[Catalyst] Serving static content
Chisel Wright
chisel at herlpacker.co.uk
Thu Jun 9 18:31:22 CEST 2005
I'm a tad confused about some different behaviour between ap_server.pl
and app_test.pl.
I have a tiny app with a comtroller Static.pm, containing a default
method and a begin method:
sub default : Private {
my ( $self, $c ) = @_;
unless ($c->serve_static) {
$c->res->output('static content not found');
}
}
sub begin : Private {
my ($self, $c) = @_;
# do nothing - this just stops us hitting Cycling->begin()
}
If I do:
./script/app_test.pl http://ferrari:3000/static/bikelogo.jpg
I get an action tree like:
I get an action tree like:
.=-------------------
| Action
|=-----------------
| /static/begin
| /static/default
| /end
'=------------------
However, if I run:
./script/app_server.pl
and point my browser at http://ferrari:3000/static/bikelogo.jpg I get an
action tree like:
:
./script/app_server.pl
and point my browser at http://ferrari:3000/static/bikelogo.jpg I get an
action tree like:
.=------------------------------------------
| Action
|=----------------------------------------
| /static/begin
| /static/default
| -> /statistic/list_statistics
| -> /statistic/list
| -> Cycling::V::TT->process
| /end
'=---------------------------------
Can anyone suggest a reason why the server would want to call
/statistic/list_statistics and /statistic/list and
Cycling::V::TT->process while the test script doesn't?
It might be relevant, my App.pm has the following end() function,
although I don't quite understand why the two methods behave
differently.
sub end : Private {
my ($self, $c) = @_;
unless ($c->stash->{'template'} || $c->res->output) {
$c->forward('/statistic/list');
}
unless ($c->res->body) {
$c->forward('Cycling::V::TT');
}
# fill in any forms
$c->fillform( $c->stash->{'form_values'} )
if (exists $c->stash->{'form_values'});
# sometimes suicide is requested
die if $c->req->params->{'die'};
}
Chisel
--
Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/
More information about the Catalyst
mailing list