Skip to content

Instantly share code, notes, and snippets.

@hayajo
Created September 8, 2011 05:23
Show Gist options
  • Save hayajo/1202693 to your computer and use it in GitHub Desktop.
Save hayajo/1202693 to your computer and use it in GitHub Desktop.
Plack::Middleware::Auth::Basic::Ex - Basic認証を除外するパスに対応
package Plack::Middleware::Auth::Basic::Ex;
use strict;
use warnings;
use parent qw/Plack::Middleware::Auth::Basic/;
use Plack::Util::Accessor qw( exclude_path );
sub prepare_app {
my $self = shift;
$self->SUPER::prepare_app;
my $regex = $self->exclude_path;
if ($regex && uc(ref $regex) ne 'REGEXP') {
die 'exclude_path should be a regexp reference';
}
}
sub call {
my($self, $env) = @_;
my $path = $env->{PATH_INFO};
if (my $regex = $self->exclude_path) {
return $self->app->($env) if ($path =~ m/$regex/);
}
$self->SUPER::call($env);
}
1
@hayajo
Copy link
Author

hayajo commented Sep 8, 2011

あとでリストに対応する

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment