Scroll to navigation

Lemonldap::NG::Handler::PSGI::Try(3pm) User Contributed Perl Documentation Lemonldap::NG::Handler::PSGI::Try(3pm)


Lemonldap::NG::Handler::PSGI::Try - Special handler for Lemonldap::NG Portal


  package My::PSGI;
  use base Lemonldap::NG::Handler::PSGI::Try;
  sub init {
    my ($self,$args) = @_;
    # Declare REST routes for authenticated users (could be HTML templates or
    # methods)
    $self->addAuthRoute ( 'index.html', undef, ['GET'] )
         ->addAuthRoute ( books => { ':book' => 'booksMethod' }, ['GET', 'POST'] );
    # Default route (ie: PATH_INFO == '/')
    # Same for unauthenticated users
    $self->addUnauthRoute ( 'login.html', undef, ['GET'] )
         ->addUnauthRoute ( 'login', undef, ['POST'] );
    # Return a boolean. If false, then error message has to be stored in
    # $self->error
    return 1;
  sub booksMethod {
    my ( $self, $req, @otherPathInfo ) = @_;

    # Will be called only if authorized
    my $userId = $self->userId;
    my $book = $req->params('book');
    my $method = $req->method;


Lemonldap::NG::Handler::PSGI::Try is a Lemonldap::NG::Handler::PSGI::Router package that provides 2 REST routers: one for authenticated users and one for unauthenticated users.


Same as Lemonldap::NG::Handler::PSGI::Router (inherits from Lemonldap::NG::Common::PSGI::Router) except that:
addRoute() must be replaced by addAuthRoute() or addUnauthRoute()
defaultRoute() must be replaced by defaultAuthRoute() or defaultUnauthRoute()

Note also that user session datas are available in $req parameter (first argument received by REST methods):

$req->userData() returns a hash reference containing user session data


See Lemonldap::NG::Common::PSGI::Router for more.


LemonLDAP::NG team <>


Use OW2 system to report bug or ask for features: <>


Lemonldap::NG is available at <>


See COPYING file for details.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <>.

2021-02-11 perl v5.32.1