lemonldap-ng/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Plugin.pm

54 lines
1.1 KiB
Perl
Raw Normal View History

2016-06-09 20:40:20 +02:00
# Base package for LLNG portal plugins. It adds somme wrapper to
# Lemonldap::NG::Handler::PSGI::Try (base of portal)
2016-05-28 10:33:39 +02:00
package Lemonldap::NG::Portal::Main::Plugin;
use strict;
use Mouse;
our $VERSION = '2.0.0';
2016-06-02 23:20:36 +02:00
extends 'Lemonldap::NG::Common::Module';
2016-05-28 10:33:39 +02:00
2017-01-09 07:11:28 +01:00
sub sendError {
my $self = shift;
return $self->p->sendError(@_);
}
sub sendJSONresponse {
my $self = shift;
return $self->p->sendJSONresponse(@_);
}
2016-05-28 10:33:39 +02:00
sub addAuthRoute {
my $self = shift;
return $self->_addRoute( 'addAuthRoute', @_ );
2016-05-28 10:33:39 +02:00
}
sub addUnauthRoute {
my $self = shift;
return $self->_addRoute( 'addUnauthRoute', @_ );
2016-05-28 10:33:39 +02:00
}
sub _addRoute {
my ( $self, $type, $word, $subName, $methods, $transform ) = @_;
$transform //= sub {
my ($sub) = @_;
if ( ref $sub ) {
return sub {
shift;
return $sub->( $self, @_ );
}
}
else {
return sub {
shift;
return $self->$sub(@_);
}
}
};
$self->p->$type( $word, $subName, $methods, $transform );
return $self;
2016-05-28 10:33:39 +02:00
}
1;