[Catalyst] Serving server-dependent static content

Matt S Trout dbix-class at trout.me.uk
Mon Aug 13 12:08:41 GMT 2007

On Sun, Aug 12, 2007 at 03:49:40PM -0400, Andy Grundman wrote:
> On Aug 12, 2007, at 2:22 PM, Peter Lytle wrote:
> >Good afternoon - I am working on a Catalyst application that serves  
> >dynamic website content for multiple sites, and I've run into some  
> >difficulty about static content.  Each website has unique static  
> >content (images, css, rss) and I am trying to serve that static  
> >content from the site's unique directory.  I have found lots of  
> >documentation on how to serve all static content from a single  
> >directory, but not much on a servername-dependent directory.  For  
> >example:
> >
> >Request:  http://www.timjohnson.com/css/global.css
> >Should be served with:  /var/www/html/sites/timjohnson.com/css/ 
> >global.css
> >
> >I came close to making this happen just using the Alias directive  
> >in httpd.conf, but I couldn't get that to accept a variable, % 
> >{SERVER_NAME}, in it.  If someone has a solution from the Apache  
> >side, that's fine but I suspect that it might be easier to do this  
> >with Catalyst::Plugin::Static::Simple, though I again have not  
> >figured out how to tell it to use a variable name when it creates  
> >the path the request is supposed to be mapped to.  I am sending  
> >this to the Catalyst list because I suspect it might be something  
> >other people have faced before using Catalyst.
> >
> >My setup is a recent version of Catalyst running on Apache 2.2 with  
> >mod_perl.  Any suggestions would be quite welcome - thank you very  
> >much.
> As has already been said, you should use Apache for this.  But if you  
> *really* want to use Static::Simple, take a look at the docs for the  
> "Including additional directories", and in particular the  
> incpath_generator sample code.  You can write a bit of code that  
> returns one or more directories from which to serve static content.

Did we make _serve_static_file public yet? Having a way to do something
like that dynamically is the one thing I still -really- miss from the old
Static plugin.

... alternatively, we could always have Controller::Static blah blah plugins
evil blah yadda no really this time a plugin's fine :)

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/                    http://www.shadowcat.co.uk/ 

More information about the Catalyst mailing list