Dancer2::Plugin::RootURIFor - Mountpoint-agnostic uri builder for Dancer2
Version 0.03
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'); };
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.
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'
John Barrett, <john@jbrt.org>
http://github.com/jbarrett/Dancer2-Plugin-RootURIFor
Please direct all requests to http://github.com/jbarrett/Dancer2-Plugin-RootURIFor/issues or email <john@jbrt.org>.
Copyright 2015 John Barrett.
This application is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Thanks to Sawyer X for sanity check and feedback.
Dancer2
"uri_for" in Dancer2::Manual
To install Dancer2::Plugin::RootURIFor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Plugin::RootURIFor
CPAN shell
perl -MCPAN -e shell install Dancer2::Plugin::RootURIFor
For more information on module installation, please visit the detailed CPAN module installation guide.