Proposed plugin Dancer2::Plugin::RootURIFor
Hey all, Following some discussion on #dancer today, I have a couple of questions. Firstly, before I go ahead and wrap this in tests and CPAN-ify it, does it seem useful? Dancer2::Plugin::RootURIFor provides root_uri_for, which is the same as uri_for except it ignores your application's mount point / base path. The use-case for this is if you have multiple applications and would like to construct links between them (or to other resources) which retain URI scheme, host, port etc. e.g. You have two apps, mounted on /app1 and /app2. Calling: uri_for '/app2' ...from app1 will give you 'http://.../app1/app2'. Calling: root_uri_for '/app2' ...from app1 will give you 'http://.../app2'. First pass: <https://gist.github.com/jbarrett/e568195bbb6fe5aec9ae> Secondly, is there a better or more idiomatic way to achieve this? Does this function already exist? Thanks.
Hi John, This sounds good to me. I only have one comment: * The DSL is available in plugins. You don't need to go to $app->request. You can just call "request". On Tue, Apr 14, 2015 at 8:05 PM, John Barrett <john@jbrt.org> wrote:
Hey all,
Following some discussion on #dancer today, I have a couple of questions. Firstly, before I go ahead and wrap this in tests and CPAN-ify it, does it seem useful?
Dancer2::Plugin::RootURIFor provides root_uri_for, which is the same as uri_for except it ignores your application's mount point / base path. The use-case for this is if you have multiple applications and would like to construct links between them (or to other resources) which retain URI scheme, host, port etc.
e.g. You have two apps, mounted on /app1 and /app2. Calling:
uri_for '/app2'
...from app1 will give you 'http://.../app1/app2'. Calling:
root_uri_for '/app2'
...from app1 will give you 'http://.../app2'.
First pass:
<https://gist.github.com/jbarrett/e568195bbb6fe5aec9ae>
Secondly, is there a better or more idiomatic way to achieve this? Does this function already exist?
Thanks. _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Sun, 19 Apr 2015 13:57:26 +0200 Sawyer X <xsawyerx@gmail.com> wrote:
This sounds good to me. I only have one comment: * The DSL is available in plugins. You don't need to go to $app->request. You can just call "request".
Good call. Thanks, Sawyer! Should be out this week. Appreciate the feedback. Cheers, John.
participants (2)
-
John Barrett -
Sawyer X