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

Assaf Gordon gordon at cshl.edu
Wed Sep 14 19:13:10 CEST 2011


Hello,

(Somewhat related to the previous thread of "Deploying many many apps")

Is there a way to specify a application-wide "prefix" settings ?
The "prefix" keyword affects only the routes subroutines, but not the static/public files.

For example,
With WSGI/Pylon, they have a "prefix" settings that can be specified in the INI file, and that affects all the components of the application (including static files).
This allows the following:
1. Write your application as usual
   (so route '/' is really '/', and images are /images/XXXX.jpg and javascripts are in /javascript/XXXX.js, etc.)

2. Add a "prefix" setting to the INI file (e.g. "prefix=dancer"),
   now:
     the root route because "/dancer/",
     images come from /dancer/images/XXXX.jpg
     javascripts come from /dancer/javascripts/XXXXX.js
     css files come from /dancer/css/XXXXXX.css
     etc.

3. In Apache (or NGinx), do something like:
     RewriteRule ^/dancer/images/(.*) /home/gordon/projects/my_dancer_app/public/images/$1 [L]
     RewriteRule ^/dancer/javascripts/(.*) /home/gordon/projects/my_dancer_app/public/javascripts/$1 [L]
     RewriteRule ^/dancer/css/(.*) /home/gordon/projects/my_dancer_app/public/css/$1 [L]
     RewriteRule ^/dancer(.*) http://localhost:3000$1 [P]
 

The outcome:
1. Static content is served by Apache directly, doesn't even go to the application (based on a "rewrite_rule").
2. Multiple applications can be deployed with different URL-prefix, without changing a single line of code in the application (just in the INI file).

Does Dancer support something similar ?
I haven't deployed a production server yet, but I'm planning do do so with several applications running on the same server (with different prefixes),
and after reading Dancer::Deployment I'm still not sure what's the recommended way to do so.


suggestions are very welcomed,
 -gordon


More information about the Dancer-users mailing list