NAME
Dancer2::Plugin::RootURIFor - Mountpoint-agnostic uri builder for Dancer2
VERSION
Version 0.02
SYNOPSIS
In your PSGI runner, you have multiple apps:
builder {
mount '/app1' => App1->to_app;
mount '/app2' => App2->to_app;
}
In your app, you would like to redirect or link between them:
package App1;
use Dancer2;
use Dancer2::Plugin::RootURIFor;
get '/redir' => sub {
redirect root_uri_for('/app2');
};
DESCRIPTION
Dancer2::Plugin::RootURIFor provides a way to link to resources on your service which reside outside your application's mount point. This is useful as we can retain URI scheme, server name, port etc. without resorting to querying request parameters.
It should act exactly like uri_for, except it simply ignores the application's base uri.
FUNCTIONS
root_uri_for
Returns a URI with the server's root URI as its base.
root_uri_for '/hello';
# Returns something like 'https://yourservice/hello'
You can also pass a hashref to generate URI parameters:
root_uri_for '/hello', { looking_for => 'me' };
# Returns something like 'https://yourservice/hello?looking_for=me'
AUTHOR
John Barrett, <john@jbrt.org>
CONTRIBUTING
http://github.com/jbarrett/Dancer2-Plugin-RootURIFor
BUGS AND SUPPORT
Please direct all requests to http://github.com/jbarrett/Dancer2-Plugin-RootURIFor/issues or email <john@jbrt.org>.
COPYRIGHT
Copyright 2015 John Barrett.
LICENSE
This application is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
ACKNOWLEDGEMENTS
Thanks to Sawyer X for sanity check and feedback.