daily pastebin goal
57%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Plack::Middleware::Auth::Basic::Ex;
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use parent qw/Plack::Middleware::Auth::Basic/;
  7. use Plack::Util::Accessor qw( exclude_path );
  8.  
  9. sub prepare_app {
  10.     my $self = shift;
  11.     $self->SUPER::prepare_app;
  12.  
  13.     my $regex = $self->exclude_path;
  14.     if ($regex && uc(ref $regex) ne 'REGEXP') {
  15.         die 'exclude_path should be a regexp reference';
  16.     }
  17. }
  18.  
  19. sub call {
  20.     my($self, $env) = @_;
  21.     my $path = $env->{PATH_INFO};
  22.     if (my $regex = $self->exclude_path) {
  23.         return $self->app->($env) if ($path =~ m/$regex/);
  24.     }
  25.     $self->SUPER::call($env);
  26. }
  27.  
  28. 1;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top