Lemonldap::NG::Handler::PSGI::Try(3pm)

Lemonldap::NG::Handler::PSGI::Try3pm

Special handler for lemonldap::ng portal

Usage

  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 == '/')
    $self->defaultAuthRoute('index.html');
  
    # Same for unauthenticated users
    $self->addUnauthRoute ( 'login.html', undef, ['GET'] )
         ->addUnauthRoute ( 'login', undef, ['POST'] );
    $self->defaultUnauthRoute('login.html');
   
    # 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;
    ...
    $self->sendJSONresponse(...);
  }

Overview

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.

Methods

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

Bug report

Use OW2 system to report bug or ask for features: <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>

Download

Lemonldap::NG is available at <https://lemonldap-ng.org/download>

Releases

4 releases since Debian 10 (Buster); the text changed 3 times.

  1. 10
  2. 11
  3. 12
  4. 13

Authors

LemonLDAP::NG team <http://lemonldap-ng.org/team>

From liblemonldap-ng-handler-perl 2.21.2+ds-1+deb13u3 in Debian 13 (Trixie). Parsed by carta from the page's man source.