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->errorreturn 1;}sub booksMethod {my ( $self, $req, @otherPathInfo ) = @_;# Will be called only if authorizedmy $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 byaddAuthRoute()oraddUnauthRoute()
defaultRoute()must be replaced bydefaultAuthRoute()ordefaultUnauthRoute()
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>
Copyright and license
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 <http://www.gnu.org/licenses/>.
Releases
4 releases since Debian 10 (Buster); the text changed 3 times.