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 == '/') $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(...); }
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:
Note also that user session datas are available in $req parameter (first argument received by REST methods):
See Lemonldap::NG::Common::PSGI::Router for more.
Use OW2 system to report bug or ask for features: <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
Lemonldap::NG is available at <https://lemonldap-ng.org/download>
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/>.
2024-02-07 | perl v5.38.2 |