lemonldap-ng/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Server.pm

33 lines
736 B
Perl
Raw Normal View History

package Lemonldap::NG::Handler::PSGI::Server;
use strict;
use Mouse;
2016-01-26 07:14:54 +01:00
use Lemonldap::NG::Handler::SharedConf qw(:tsv);
extends 'Lemonldap::NG::Handler::PSGI';
sub router {
return [ 200, [], [] ];
}
sub _run {
my $self = shift;
2016-01-26 07:14:54 +01:00
return sub {
my $req = $_[0];
$self->lmLog( 'New request', 'debug' );
my $res = $self->_authAndTrace(
Lemonldap::NG::Common::PSGI::Request->new( $_[0] ) );
2016-01-26 07:14:54 +01:00
2016-01-29 12:09:55 +01:00
# Transform 302 responses in 401 since Nginx refuse it
if($res->[0] == 302 or $res->[0] == 303) {
$res->[0] = 401;
2016-01-29 12:09:58 +01:00
push @{$res->[1]},'X-Location' => $tsv->{portal}->();
2016-01-29 12:09:55 +01:00
}
2016-01-26 07:14:54 +01:00
# TODO: transform headers in $res->[1]
return $res;
};
}
1;