Dancer::Plugin::ProxyPath - Provides user-perspective paths
This module provides an alternative to using request->uri_for, which provides server perspective paths. The paths produced by this module are made using headers provided by Apache to determine what the path should be from the requester's perspective. This is useful when you have deployed your Dancer app using the ReverseProxy method: http://search.cpan.org/~sukria/Dancer-1.3002/lib/Dancer/Deployment.pod#Using_Apache's_mod_proxy
use Dancer::Plugin::ProxyPath; my $internal_path = request->uri_for("/path/to/elsewhere"); # http://private.server.com:5000/path/to/elsewhere my $external_path = proxy->uri_for("/path/to/elsewhere"); # http://public.server.com/dancer-app/path/to/elsewhere ... # and in your templates: (assuming a passed variable $background) <body style="background-image: url('<% proxy.uri_for(background) %>')"> </body>
If no proxy information is found, proxy->uri_for will return the same paths as request->uri_for, making it work in development as well.
If the proxy is not mounted at the root level, you will need to pass along the mounted location, using a header (See README). You can set the name of the header you have chosen with the plugin setting "base_header"
One function is exported by default: proxy
Returns the proxy object, which has two methods: path and uri_for.
<alex kalderimis at gmail dot com>
Please report any bugs or feature requests to
bug-dancer-plugin-proxypath at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-ProxyPath. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Dancer obviously, for being a great way to write a web-app.
Copyright 2011 Alex Kalderimis.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.