Apache2-API
view release on metacpan or search on metacpan
## decode\_url( $string )
Given a url-encoded string, this returns the decoded string using ["decode" in APR::Request](https://metacpan.org/pod/APR%3A%3ARequest#decode)
## decode\_utf8( $data )
Decode some data from ut8 into perl internal utf8 representation using [Encode](https://metacpan.org/pod/Encode)
If an error occurs, it will return undef and set an exception that can be accessed with the [error](https://metacpan.org/pod/Module%3A%3AGeneric#errir) method.
## encode\_base64( $data )
Given some data, this will encode it using base64 algorithm. It uses ["encode" in APR::Base64](https://metacpan.org/pod/APR%3A%3ABase64#encode).
## encode\_json( $hash\_reference )
Given a hash reference, this will encode it into a json data representation.
However, this will not utf8 encode it, because this is done upon printing the data and returning it to the client.
The JSON object has the following properties enabled: `allow_nonref`, `allow_blessed`, `convert_blessed` and `relaxed`
## encode\_url( $string )
Given a string, this returns its url-encoded version using ["encode" in APR::Request](https://metacpan.org/pod/APR%3A%3ARequest#encode)
## encode\_utf8( $data )
This encode in ut8 the data provided and return it.
If an error occurs, it will return undef and set an exception that can be accessed with the **error** method.
## generate\_uuid
Generates an uuid string and return it. This uses [APR::UUID](https://metacpan.org/pod/APR%3A%3AUUID)
## get\_auth\_bearer
Checks whether an `Authorization` HTTP header was provided, and get the Bearer value.
If no header was found, it returns an empty string.
If an error occurs, it will return undef and set an exception that can be accessed with the **error** method.
## get\_handlers
Returns a reference to a list of handlers enabled for a given phase.
$handlers_list = $res->get_handlers( $hook_name );
A list of handlers configured to run at the child\_exit phase:
@handlers = @{ $res->get_handlers( 'PerlChildExitHandler' ) || []};
## gettext( 'string id' )
Get the localised version of the string passed as an argument.
This is supposed to be superseded by the package inheriting from [Apache2::API](https://metacpan.org/pod/Apache2%3A%3AAPI), if any.
## header\_datetime( DateTime object )
Given a [DateTime](https://metacpan.org/pod/DateTime) object, this sets it to GMT time zone and set the proper formatter ([Apache2::API::DateTime](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3ADateTime)) so that the stringification is compliant with...
## htpasswd
my $ht = $api->htpasswd( $clear_password, create => 1 );
my $ht = $api->htpasswd( $clear_password, create => 1, salt => $salt );
my $ht = $api->htpasswd( $md5_password );
my $bool = $ht->matches( $user_input_password );
This instantiates a new [Apache2::API::Password](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3APassword) object by providing its constructor whatever arguments was received.
It returns a new [Apache2::API::Password](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3APassword) object, or, upon error, `undef` in scalar context, or an empty list in list context.
## is\_perl\_option\_enabled
Checks if perl option is enabled in the Virtual Host and returns a boolean value
## json
Returns a JSON object.
You can provide an optional hash or hash reference of properties to enable or disable:
my $J = $api->json( pretty => 1, relaxed => 1 );
Each property corresponds to one that is supported by [JSON](https://metacpan.org/pod/JSON)
It also supports `ordered`, `order` and `sort` as an alias to `canonical`
## lang( $string )
Set or get the language for the API. This would typically be the HTTP preferred language.
## lang\_unix( $string )
Given a language, this returns a language code formatted the unix way, ie en-GB would become en\_GB
## lang\_web( $string )
Given a language, this returns a language code formatted the web way, ie en\_GB would become en-GB
## log
$api->log->emerg( "Urgent message." );
$api->log->alert( "Alert!" );
$api->log->crit( "Critical message." );
$api->log->error( "Error message." );
$api->log->warn( "Warning..." );
$api->log->notice( "You should know." );
$api->log->info( "This is for your information." );
$api->log->debug( "This is debugging message." );
Returns a [Apache2::Log::Request](https://metacpan.org/pod/Apache2%3A%3ALog%3A%3ARequest) object.
## log\_error( $string )
Given a string, this will log the data into the error log.
When log\_error is accessed with the [Apache2::RequestRec](https://metacpan.org/pod/Apache2%3A%3ARequestRec) the error gets logged into the Virtual Host log, but when log\_error gets accessed via the [Apache2::ServerUtil](https://metacpan.org/pod/Apa...
## print( @list )
- `-order=mode`
run the tests in one of the modes: (repeat|random|SEED)
- `-ping[=block]`
test if server is running or port in use
- `-post`
POST url
- `-postamble`
config to add at the end of `httpd.conf`
- `-preamble`
config to add at the beginning of `httpd.conf`
- `-proxy`
proxy requests (default proxy is localhost)
- `-run-tests`
run the tests
- `-ssl`
run tests through ssl
- `-start-httpd`
start the test server
- `-stop-httpd`
stop the test server
- `-trace=T`
change tracing default to: warning, notice, info, debug, ...
- `-verbose[=1]`
verbose output
See for more information [https://perl.apache.org/docs/general/testing/testing.html](https://perl.apache.org/docs/general/testing/testing.html)
## API CORE MODULES
[Apache2::RequestIO](https://metacpan.org/pod/Apache2%3A%3ARequestIO), [Apache2::RequestRec](https://metacpan.org/pod/Apache2%3A%3ARequestRec)
# AUTHOR
Jacques Deguest <`jack@deguest.jp`>
# SEE ALSO
[Apache2::API::DateTime](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3ADateTime), [Apache2::API::Query](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3AQuery), [Apache2::API::Request](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3ARequest), [Apache2:...
[Apache2::Request](https://metacpan.org/pod/Apache2%3A%3ARequest), [Apache2::RequestRec](https://metacpan.org/pod/Apache2%3A%3ARequestRec), [Apache2::RequestUtil](https://metacpan.org/pod/Apache2%3A%3ARequestUtil)
# COPYRIGHT & LICENSE
Copyright (c) 2023 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated
files under the same terms as Perl itself.
( run in 0.408 second using v1.01-cache-2.11-cpan-524268b4103 )