blob: 08ff41fdba9fba55e517e95cbf972f700b933c16 [file] [log] [blame]
Nils Diewald2fe12e12015-03-06 16:47:06 +00001package Kalamar::Plugin::KalamarHelpers;
2use Mojo::Base 'Mojolicious::Plugin';
3
4sub 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
251;