Dancer::Plugin::ProxyPath - Provides user-perspective paths
Version 0.03
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
Supposing a Dancer app hosted on http://private.server.com:5000 but reachable at http://public.server.com/dancer-app, the following should apply:
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.
See Dancer::Plugin::ProxyPath::Proxy
Alex Kalderimis, <alex kalderimis at gmail dot com>
<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.
bug-dancer-plugin-proxypath at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Dancer::Plugin::ProxyPath
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-ProxyPath
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Dancer-Plugin-ProxyPath
CPAN Ratings
http://cpanratings.perl.org/d/Dancer-Plugin-ProxyPath
Search CPAN
http://search.cpan.org/dist/Dancer-Plugin-ProxyPath/
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.
To install Dancer::Plugin::ProxyPath, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Plugin::ProxyPath
CPAN shell
perl -MCPAN -e shell install Dancer::Plugin::ProxyPath
For more information on module installation, please visit the detailed CPAN module installation guide.