logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

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

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>

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.

Download

       Lemonldap::NG is available at <https://lemonldap-ng.org/download>

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

Name

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

See Also

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

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

See Also