Created
September 8, 2011 05:23
-
-
Save hayajo/1202693 to your computer and use it in GitHub Desktop.
Plack::Middleware::Auth::Basic::Ex - Basic認証を除外するパスに対応
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
あとでリストに対応する