NAME
Lemonldap::NG::Handler::PSGI::Try - Special handler for Lemonldap::NG Portal
SYNOPSIS
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(...);
}
DESCRIPTION
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):
SEE ALSO
See Lemonldap::NG::Common::PSGI::Router for more.
AUTHORS
- LemonLDAP::NG team http://lemonldap-ng.org/team
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 http://forge.objectweb.org/project/showfiles.php?group_id=274
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/.