Apache2-API
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
my $f = File::Spec->catfile( $base, 'apache2.conf' );
my $old = File::Spec->catfile( $base, 'httpd.conf' );
my $env = File::Spec->catfile( $base, 'envvars' );
if( -e( $f ) && -r( $f ) )
{
print( STDERR "Found an Apache configuration at '$f'\n" ) if( $MY_DEBUG );
if( -e( $env ) && -r( $env ) && ( $^O eq 'darwin' || $^O eq 'linux' ) )
{
print( STDERR "Found an Apache environment variables setup at '$env'\n" ) if( $MY_DEBUG );
my $fh;
# Credits: <https://stackoverflow.com/a/3836009/4814971>
if( defined( $fh = IO::File->new( "sh -x $env 2>&1 1>/dev/null|" ) ) )
{
my $vars = {};
while( defined( $_ = $fh->getline ) )
{
chomp;
if( /^[[:blank:]\h]*\+[[:blank:]\h]+(?:export[[:blank:]\h]+)?(\w+)\=(.*?)$/ )
{
next unless( substr( $1, 0, 7 ) eq 'APACHE_' );
$vars->{ $1 } = $ref->{ "_$1" } = $2;
server_version
Tries hard to find out the version number of the Apache server. This
returns the value from "server_version" in Apache2::API::Request
set_handlers()
Returns the values from "set_handlers" in Apache2::Server by passing it
whatever arguments were provided.
use_rfc_error
Boolean. When true, this will return rfc9457 style error
<https://www.rfc-editor.org/rfc/rfc9457.html>
warn( @list )
Given a list of string, this sends a warning using "warn" in
Apache2::Log
_try( $object_type, $method_name, @_ )
Given an object type, a method name and optional parameters, this
attempts to call it, passing it whatever arguments were provided and
return its return values.
## server\_version
Tries hard to find out the version number of the Apache server. This returns the value from ["server\_version" in Apache2::API::Request](https://metacpan.org/pod/Apache2%3A%3AAPI%3A%3ARequest#server_version)
## set\_handlers()
Returns the values from ["set\_handlers" in Apache2::Server](https://metacpan.org/pod/Apache2%3A%3AServer#set_handlers) by passing it whatever arguments were provided.
## use\_rfc\_error
Boolean. When true, this will return rfc9457 style error [https://www.rfc-editor.org/rfc/rfc9457.html](https://www.rfc-editor.org/rfc/rfc9457.html)
## warn( @list )
Given a list of string, this sends a warning using ["warn" in Apache2::Log](https://metacpan.org/pod/Apache2%3A%3ALog#warn)
## \_try( $object\_type, $method\_name, @\_ )
Given an object type, a method name and optional parameters, this attempts to call it, passing it whatever arguments were provided and return its return values.
Apache2 methods are designed to die upon error, whereas our model is based on returning `undef` and setting an exception with [Module::Generic::Exception](https://metacpan.org/pod/Module%3A%3AGeneric%3A%3AException), because we believe that only the ...
lib/Apache2/API.pm view on Meta::CPAN
# push_handlers($hook_name => \&handler);
# push_handlers($hook_name => [\&handler, \&handler2]);
sub push_handlers { return( shift->_try( 'server', 'push_handlers', @_ ) ); }
# See also <https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/406>
sub reply
{
my $self = shift( @_ );
my( $code, $ref );
my $use_rfc_error = $self->{use_rfc_error} // $USE_RFC_ERROR;
# rfc9457 standard for REST API error response: <https://www.rfc-editor.org/rfc/rfc9457.html>
# Legacy JSON payload like Google, Twitter, Facebook
# Modern REST APIs now uses rfc9457 with a flattened payload.
# When the use_rfc_error object property is true, we use rfc9457 flattened error, this will produce something like:
# {
# error => 'not_found',
# status => 404,
# title => 'Not found!',
# detail => q{The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.},
# locale => 'en-US',
# type => 'https://api.example.com/problems/not-found',
lib/Apache2/API.pm view on Meta::CPAN
=head2 server_version
Tries hard to find out the version number of the Apache server. This returns the value from L<Apache2::API::Request/server_version>
=head2 set_handlers()
Returns the values from L<Apache2::Server/set_handlers> by passing it whatever arguments were provided.
=head2 use_rfc_error
Boolean. When true, this will return rfc9457 style error L<https://www.rfc-editor.org/rfc/rfc9457.html>
=head2 warn( @list )
Given a list of string, this sends a warning using L<Apache2::Log/warn>
=head2 _try( $object_type, $method_name, @_ )
Given an object type, a method name and optional parameters, this attempts to call it, passing it whatever arguments were provided and return its return values.
Apache2 methods are designed to die upon error, whereas our model is based on returning C<undef> and setting an exception with L<Module::Generic::Exception>, because we believe that only the main program should be in control of the flow and decide wh...
( run in 1.349 second using v1.01-cache-2.11-cpan-39bf76dae61 )