[Dancer-users] Global app-wide "prefix" settings

Assaf Gordon gordon at cshl.edu
Wed Sep 28 22:17:57 CEST 2011


Brian E. Lozier wrote, On 09/28/2011 04:14 PM:
> 
> 
> On Wed, Sep 28, 2011 at 1:07 PM, Assaf Gordon <gordon at cshl.edu <mailto:gordon at cshl.edu>> wrote:
> 
>     Has anyone been able to deploy a Dancer application *not* under the server's root URL,
>     without changing code/templates in the Dancer application itself ?
> 
> The only thing I can think of is to rewrite the html on the way out such that all calls to /images/ get the prefix.  The problem is that all your templates are hard coding a path to a resource on the server.  You're telling the browser what resource to request and you're giving it an "absolute" path.  You could also give them "relative" paths such as:
> 
> <img src="images/foo.png">
> 
> Which will work fine as long as you don't have any routes that are deeper.
> 
> Why don't you just have a configuration parameter in your config file that says "path" and then use that instead of "[% request.uri_base %]"?  I don't quite get why you're using uri_base anyway.  All you have to do is say:

This configuration parameter is exactly what started this thread (The app-wide "prefix" setting - in the subject line) :)
And I keep learning that it's a bad idea, but haven't yet understood how to do it without such parameter.


More information about the Dancer-users mailing list