1Lemonldap::NG::Handler:U:sPeSrGIC:o:nTtrryi(b3u)ted PerlLeDmoocnulmdeanpt:a:tNiGo:n:Handler::PSGI::Try(3)
2
3
4

NAME

6       Lemonldap::NG::Handler::PSGI::Try - Special handler for Lemonldap::NG
7       Portal
8

SYNOPSIS

10         package My::PSGI;
11
12         use base Lemonldap::NG::Handler::PSGI::Try;
13
14         sub init {
15           my ($self,$args) = @_;
16
17           # Declare REST routes for authenticated users (could be HTML templates or
18           # methods)
19           $self->addAuthRoute ( 'index.html', undef, ['GET'] )
20                ->addAuthRoute ( books => { ':book' => 'booksMethod' }, ['GET', 'POST'] );
21
22           # Default route (ie: PATH_INFO == '/')
23           $self->defaultAuthRoute('index.html');
24
25           # Same for unauthenticated users
26           $self->addUnauthRoute ( 'login.html', undef, ['GET'] )
27                ->addUnauthRoute ( 'login', undef, ['POST'] );
28           $self->defaultUnauthRoute('login.html');
29
30           # Return a boolean. If false, then error message has to be stored in
31           # $self->error
32           return 1;
33         }
34
35         sub booksMethod {
36           my ( $self, $req, @otherPathInfo ) = @_;
37
38           # Will be called only if authorized
39           my $userId = $self->userId;
40           my $book = $req->params('book');
41           my $method = $req->method;
42           ...
43           $self->sendJSONresponse(...);
44         }
45

DESCRIPTION

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

METHODS

52       Same as Lemonldap::NG::Handler::PSGI::Router (inherits from
53       Lemonldap::NG::Common::PSGI::Router) except that:
54
55       addRoute() must be replaced by addAuthRoute() or addUnauthRoute()
56       defaultRoute() must be replaced by defaultAuthRoute() or
57       defaultUnauthRoute()
58
59       Note also that user session datas are available in $req parameter
60       (first argument received by REST methods):
61
62       $req->userData() returns a hash reference containing user session data
63

SEE ALSO

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

AUTHORS

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

BUG REPORT

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

DOWNLOAD

75       Lemonldap::NG is available at <https://lemonldap-ng.org/download>
76
78       See COPYING file for details.
79
80       This library is free software; you can redistribute it and/or modify it
81       under the terms of the GNU General Public License as published by the
82       Free Software Foundation; either version 2, or (at your option) any
83       later version.
84
85       This program is distributed in the hope that it will be useful, but
86       WITHOUT ANY WARRANTY; without even the implied warranty of
87       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
88       General Public License for more details.
89
90       You should have received a copy of the GNU General Public License along
91       with this program.  If not, see <http://www.gnu.org/licenses/>.
92
93
94
95perl v5.38.0                      2023-11-1L4emonldap::NG::Handler::PSGI::Try(3)
Impressum