Skip to content
Browse files

Provide default Plack staff resolver function

  • Loading branch information...
1 parent 5d38de7 commit 654e489b52ec38c18f14ebb84257d3719e89bb08 @ctfliblime ctfliblime committed Jul 1, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 Koha/Plack/Rewrite.pm
View
10 Koha/Plack/Rewrite.pm
@@ -1,15 +1,21 @@
package Koha::Plack::Rewrite;
use parent qw(Plack::Middleware);
-use Modern::Perl;
+use Koha;
use Plack::Util::Accessor qw(staff_resolver);
use Carp qw(croak);
+use Koha::Plack::Util;
+
+sub is_staff {
+ my $hostname = Koha::Plack::Util::GetCanonicalHostname(shift);
+ return $hostname =~ /-staff\./;
+}
sub call {
my ($self, $env) = @_;
if (!defined $self->staff_resolver) {
- croak sprintf('Must define a "staff_resolver" function for %s.', __PACKAGE__);
+ $self->staff_resolver(\&is_staff);
}
if ($env->{REQUEST_URI} ~~ '/') {

0 comments on commit 654e489

Please sign in to comment.
Something went wrong with that request. Please try again.