Guest User

Untitled

a guest
Jan 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  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;
Add Comment
Please, Sign In to add comment