[Catalyst] serving static content from one controller?

Jonathan Rockway jon at jrock.us
Fri Oct 5 07:09:10 GMT 2007

Dustin Suchter wrote:
> I've looked into "Static::Simple", but I can't find a good
> manual/tutorial on it. I've tried to guess at how to use it but I
> pretty much didn't get anywhere.

This is probably not the best idea.  It would be better for your
Catalyst app to inform your web server as to what static page to serve. =

perlbal calls this an "internal redirect", and lighttpd calls it
"X-SendFile".  Please look into those; all your cat app will have to do
is send an HTTP header with the name of the file, and the web server
will take care of the rest.

This has come up before, I think, so grep the list archives for more detail.

Failing that, you can always set $c->res->body to a filehandle:

   sub send_static :Private {
      my ($self, $c, $filename) =3D @_;
      open my $fh, '<', $filename or die "failed to open $filename: $!";

Hopefully the internal redirects will work out for you, though.  Good luck.

Jonathan Rockway

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 370 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071005/b466=

More information about the Catalyst mailing list