The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Dancer::Plugin::ProxyPath - Provides user-perspective paths

VERSION

Version 0.03

SYNOPSIS

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"

EXPORT

One function is exported by default: proxy

SUBROUTINES

proxy

Returns the proxy object, which has two methods: path and uri_for.

See Dancer::Plugin::ProxyPath::Proxy

AUTHOR

Alex Kalderimis, <alex kalderimis at gmail dot com>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Dancer::Plugin::ProxyPath

You can also look for information at:

ACKNOWLEDGEMENTS

Dancer obviously, for being a great way to write a web-app.

LICENSE AND COPYRIGHT

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.