Apache2::REST::Request - Apache2::Request subclass.


Apache2-REST documentation Contained in the Apache2-REST distribution.

Index


Code Index:

NAME

Top

Apache2::REST::Request - Apache2::Request subclass.

DESCRIPTION

Top

This module adds extra features to the standard Apache2::Request.

As a consequence, you can use any method available on Apache2::Request, plus the additional methods below.

new

See Apache2::Request

param

See Apache2::Request::param .

This decodes the param according to $this->paramEncoding

paramEncoding

Gets/Set the paramEncoding of this Request

requestedFormat

Get/Set the requested format.

You can use this to force the returned format from a particular resource. Or to allow methods based on the format.


Apache2-REST documentation Contained in the Apache2-REST distribution.
package Apache2::REST::Request ;
use Apache2::Request ;

use base qw(Apache2::Request);

use Encode ;

sub new {
    my($class, @args) = @_;
    my $self = {
        r => Apache2::Request->new(@args) ,
        'paramEncoding' => 'UTF-8' ,
        'requestedFormat' => '' ,
    };
    return bless $self,  $class;
}

sub param{
    my ( $self , @args ) = @_ ;
    if ( wantarray ){
        my @ret = $self->{r}->param(@args) ;
        return map{ Encode::decode($self->paramEncoding() , $_ ) } @ret  ;
    }
    my $ret = $self->{r}->param(@args) ;
    return Encode::decode($self->paramEncoding() , $ret );
}

sub paramEncoding{
    my ( $self , $v ) = @_ ;
    if ( $v ){ $self->{'paramEncoding'} = $v ;}
    return $self->{'paramEncoding'} ;
}

sub requestedFormat{
    my ( $self , $v ) = @_ ;
    if ( $v ){ $self->{'requestedFormat'} = $v ;}
    return $self->{'requestedFormat'};
}


1;