Lemonldap::NG::Common::PSGI::Request(3pm)

NAME
Lemonldap::NG::Common::PSGI::Request - HTTP request object for Lemonldap::NG PSGIs

SYNOPSIS
  package My::PSGI;

  use base Lemonldap::NG::Common::PSGI;

  # See Lemonldap::NG::Common::PSGI
  ...

  sub handler {
    my ( $self, $req ) = @_;
    # Do something and return a PSGI response
    # NB: $req is a Lemonldap::NG::Common::PSGI::Request object
    if ( $req->accept eq 'text/plain' ) { ... }

    return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Body lines' ] ];
  }

DESCRIPTION
This package provides HTTP request objects used by Lemonldap::NG PSGIs. It contains common accessors to work with request. Note that it inherits from Plack::Request.

METHODS
All methods of Plack::Request are available. Lemonldap::NG::Common::PSGI::Request adds the following methods:

  accept
'Accept' header content.

  encodings
'Accept-Encoding' header content.

  error
Used to store error value (usually a Lemonldap::NG::Portal::Main::Constants constant).

  jsonBodyToObj
Get the content of a JSON POST request as Perl object.

  languages
'Accept-Language header content.

  hostname
'Host' header content.

  read-body
Since body() methods returns an IO::Handle object, this method reads and return the request content as string.

  respHeaders
Accessor to 'respHeaders' property. It is used to store headers that have to be pushed in response (see Lemonldap::NG::Common::PSGI).

Be careful, it contains an array reference, not a hash one because headers can be multi-valued.

Example:

  # Set headers
  $req->respHeaders( "Location" => "http://x.y.z/", Etag => "XYZ", );
  # Add header
  $req->respHeaders->{"X-Key"} = "Value";

  spliceHdrs
Returns headers array and flush it.

  set_param( $key, $value )
Plack::Request param() method is read-only. This method can be used to modify a GET parameter value

  uri
REQUEST_URI environment variable decoded.

  user
REMOTE_USER environment variable. It contains username when a server authentication is done.

  userData
Hash reference to the session information (if app inherits from Lemonldap::NG::Handler::PSGI or any other handler PSGI package). If no session information is available, it contains:

  { _whatToTrace => <REMOTE-USER value> }

  wantJSON
Return true if current request ask JSON content (verify that "Accept" header contains "application/json" or "text/json").

SEE ALSO
<http://lemonldap-ng.org/>, Lemonldap::NG::Common::PSGI, Lemonldap::NG::Hander::PSGI, Plack::Request, Lemonldap::NG::Portal::Main::Constants,

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/>.