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

Lemonldap::NG::Common::PSGI::Request3pm

Http request object for lemonldap::ng psgis

Usage

  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' ] ];
  }

Overview

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").

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 <https://lemonldap-ng.org/download>

Releases

5 releases since Debian 9 (Stretch); the text changed 4 times.

  1. 9
  2. 10
  3. 11
  4. 12
  5. 13

Authors

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

From liblemonldap-ng-common-perl 2.21.2+ds-1+deb13u3 in Debian 13 (Trixie). Parsed by carta from the page's man source.