Skip to content

Commit

Permalink
Issue #1136: enhance the POD
Browse files Browse the repository at this point in the history
Let the POD reflect actual usage.
Added some code tags.
  • Loading branch information
bschmalhofer committed Nov 4, 2021
1 parent bfc311d commit 95120be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
47 changes: 30 additions & 17 deletions Kernel/System/Web/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package Kernel::System::Web::Request;

## nofilter(TidyAll::Plugin::OTOBO::Perl::Pod::FunctionPod)

use strict;
use warnings;
use v5.24;
Expand Down Expand Up @@ -50,24 +52,35 @@ Holds the request params and other info on the request.
=head2 new()
create param object. Do not use it directly, instead use:
create param object. Do not use it directly, instead use it via the OTOBO object manager.
The regular usage in the web interface modules, e.g. in L<Kernel::System::Web::InterfaceAgent>.
use Kernel::System::ObjectManager;
# usually the PSGI env is already available
local $Kernel::OM = Kernel::System::ObjectManager->new(
# the PSGI env is already available in the interface modules
$Kernel::OM->ObjectParamAdd(
'Kernel::System::Web::Request' => {
PSGIEnv => $PSGIEnv
}
);
# alternatively create a request object when we are in a CGI environment
local $Kernel::OM = Kernel::System::ObjectManager->new(
# later in the code
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
In the test scripts it is convenient to pass in a request object directly.
use CGI;
use Kernel::System::UnitTest::RegisterDriver;
CGI::initialize_globals();
$Kernel::OM->ObjectParamAdd(
'Kernel::System::Web::Request' => {
WebRequest => CGI::PSGI->new($env)
WebRequest => CGI->new(),
}
);
# later in the test script or in the used modules
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
If Kernel::System::Web::Request is instantiated several times, they will share the
Expand Down Expand Up @@ -389,7 +402,7 @@ sub GetCookie {
=head2 RemoteAddr()
get the remote address of the HTTP client.
This is a wrapper around CGI::remote_addr().
This is a wrapper around C<CGI::remote_addr()>.
my $RemoteAddr = $ParamObject->RemoteAddr();
Expand All @@ -404,7 +417,7 @@ sub RemoteAddr {
=head2 RemoteUser()
get the remote user.
This is a wrapper around CGI::remote_user().
This is a wrapper around C<CGI::remote_user()>.
my $RemoteUser = $ParamObject->RemoteUser();
Expand All @@ -419,7 +432,7 @@ sub RemoteUser {
=head2 ScriptName()
return the script name as a partial URL, for self-referring scripts.
This is a wrapper around CGI::script_name().
This is a wrapper around C<CGI::script_name()>.
my $ScriptName = $ParamObject->ScriptName();
Expand All @@ -438,7 +451,7 @@ sub ScriptName {
=head2 ServerProtocol()
return info about the protocol.
This is a wrapper around CGI::server_protocol().
This is a wrapper around C<CGI::server_protocol()>.
my $ServerProtocol = $ParamObject->ServerProtocol();
Expand All @@ -453,7 +466,7 @@ sub ServerProtocol {
=head2 ServerSoftware()
return info which server is running.
This is a wrapper around CGI::server_software().
This is a wrapper around C<CGI::server_software()>.
my $ServerSoftware = $ParamObject->ServerSoftware();
Expand All @@ -468,7 +481,7 @@ sub ServerSoftware {
=head2 RequestURI()
Returns the interpreted pathname of the requested document or CGI (relative to the document root). Or undef if not set.
This is a wrapper around CGI::request_uri().
This is a wrapper around C<CGI::request_uri()>.
my $RequestURI = $ParamObject->RequestURI();
Expand All @@ -483,7 +496,7 @@ sub RequestURI {
=head2 ContentType()
Returns content-type header.
This is a wrapper around CGI::content_type().
This is a wrapper around C<CGI::content_type()>.
my $ContentType = $ParamObject->ContentType();
Expand All @@ -498,7 +511,7 @@ sub ContentType {
=head2 QueryString()
Returns the query string.
This is a wrapper around CGI::query_string().
This is a wrapper around C<CGI::query_string()>.
my $QueryString = $ParamObject->QueryString();
Expand All @@ -513,7 +526,7 @@ sub QueryString {
=head2 RequestMethod()
Usually either GET or POST.
This is a wrapper around CGI::request_method().
This is a wrapper around C<CGI::request_method()>.
my $RequestMethod = $ParamObject->RequestMethod();
Expand All @@ -528,7 +541,7 @@ sub RequestMethod {
=head2 PathInfo()
Returns additional path information from the script URL.
This is a wrapper around CGI::path_info().
This is a wrapper around C<CGI::path_info()>.
my $PathInfo = $ParamObject->PathInfo();
Expand All @@ -543,7 +556,7 @@ sub PathInfo {
=head2 HTTP()
get the HTTP environment variable. Called with a single argument get the specific environment variable.
This is a wrapper around CGI::http().
This is a wrapper around C<CGI::http()>.
my $UserAgent = $ParamObject->HTTP('USER_AGENT');
Expand Down
2 changes: 1 addition & 1 deletion bin/psgi-bin/otobo.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ my $ExactlyRootMiddleware = sub {

# With S3 support, loader files are initially stored in S3.
# Sync them to the local file system so that Plack::App::File can deliver them.
# Checking the namee is sufficient as the loader files contain a checksum.
# Checking the name is sufficient as the loader files contain a checksum.
my $SyncFromS3Middleware = sub {
my $App = shift;

Expand Down

0 comments on commit 95120be

Please sign in to comment.