1Lemonldap::NG::Common::UPsSeGrI:C:oRnetqruiebsutt(e3d)PLeermlonDlodcaupm:e:nNtGa:t:iCoonmmon::PSGI::Request(3)
2
3
4
6 Lemonldap::NG::Common::PSGI::Request - HTTP request object for
7 Lemonldap::NG PSGIs
8
10 package My::PSGI;
11
12 use base Lemonldap::NG::Common::PSGI;
13
14 # See Lemonldap::NG::Common::PSGI
15 ...
16
17 sub handler {
18 my ( $self, $req ) = @_;
19 # Do something and return a PSGI response
20 # NB: $req is a Lemonldap::NG::Common::PSGI::Request object
21 if ( $req->accept eq 'text/plain' ) { ... }
22
23 return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Body lines' ] ];
24 }
25
27 This package provides HTTP request objects used by Lemonldap::NG PSGIs.
28 It contains common accessors to work with request. Note that it
29 inherits from Plack::Request.
30
32 All methods of Plack::Request are available.
33 Lemonldap::NG::Common::PSGI::Request adds the following methods:
34
35 accept
36 'Accept' header content.
37
38 encodings
39 'Accept-Encoding' header content.
40
41 error
42 Used to store error value (usually a
43 Lemonldap::NG::Portal::Main::Constants constant).
44
45 jsonBodyToObj
46 Get the content of a JSON POST request as Perl object.
47
48 languages
49 'Accept-Language header content.
50
51 hostname
52 'Host' header content.
53
54 read-body
55 Since body() methods returns an IO::Handle object, this method reads
56 and return the request content as string.
57
58 respHeaders
59 Accessor to 'respHeaders' property. It is used to store headers that
60 have to be pushed in response (see Lemonldap::NG::Common::PSGI).
61
62 Be careful, it contains an array reference, not a hash one because
63 headers can be multi-valued.
64
65 Example:
66
67 # Set headers
68 $req->respHeaders( "Location" => "http://x.y.z/", Etag => "XYZ", );
69 # Add header
70 $req->respHeaders->{"X-Key"} = "Value";
71
72 spliceHdrs
73 Returns headers array and flush it.
74
75 set_param( $key, $value )
76 Plack::Request param() method is read-only. This method can be used to
77 modify a GET parameter value
78
79 uri
80 REQUEST_URI environment variable decoded.
81
82 user
83 REMOTE_USER environment variable. It contains username when a server
84 authentication is done.
85
86 userData
87 Hash reference to the session information (if app inherits from
88 Lemonldap::NG::Handler::PSGI or any other handler PSGI package). If no
89 session information is available, it contains:
90
91 { _whatToTrace => <REMOTE-USER value> }
92
93 wantJSON
94 Return true if current request ask JSON content (verify that "Accept"
95 header contains "application/json" or "text/json").
96
98 <http://lemonldap-ng.org/>, Lemonldap::NG::Common::PSGI,
99 Lemonldap::NG::Hander::PSGI, Plack::Request,
100 Lemonldap::NG::Portal::Main::Constants,
101
103 LemonLDAP::NG team <http://lemonldap-ng.org/team>
104
106 Use OW2 system to report bug or ask for features:
107 <https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
108
110 Lemonldap::NG is available at <https://lemonldap-ng.org/download>
111
113 See COPYING file for details.
114
115 This library is free software; you can redistribute it and/or modify it
116 under the terms of the GNU General Public License as published by the
117 Free Software Foundation; either version 2, or (at your option) any
118 later version.
119
120 This program is distributed in the hope that it will be useful, but
121 WITHOUT ANY WARRANTY; without even the implied warranty of
122 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
123 General Public License for more details.
124
125 You should have received a copy of the GNU General Public License along
126 with this program. If not, see <http://www.gnu.org/licenses/>.
127
128
129
130perl v5.36.1 2023-1L1e-m1o4nldap::NG::Common::PSGI::Request(3)