Nils Diewald | 2fe12e1 | 2015-03-06 16:47:06 +0000 | [diff] [blame^] | 1 | package Kalamar::Plugin::KalamarHelpers; |
| 2 | use Mojo::Base 'Mojolicious::Plugin'; |
| 3 | |
| 4 | sub register { |
| 5 | my ($plugin, $mojo) = @_; |
| 6 | |
| 7 | $mojo->helper( |
| 8 | kalamar_test_port => sub { |
| 9 | my $c = shift; |
| 10 | if (defined $c->stash('kalamar.test_port')) { |
| 11 | return $c->stash('kalamar.test_port'); |
| 12 | }; |
| 13 | |
| 14 | if ($c->req->url->to_abs->port == 6666 || |
| 15 | $c->app->mode =~ m/^development|test$/) { |
| 16 | $c->stash('kalamar.test_port' => 1); |
| 17 | return 1; |
| 18 | }; |
| 19 | |
| 20 | $c->stash('kalamar.test_port' => 0); |
| 21 | return 0; |
| 22 | }); |
| 23 | }; |
| 24 | |
| 25 | 1; |