Apache2::REST::Handler::test


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

Index


Code Index:

NAME

Apache2::REST::Handler::test - test handler access '/test/' to test your installation

GET

POST

Performs a fake POST

PUT

Performs a fake PUT

DELETE

Performs a fake DELETE

buildNext

Builds a new test::user using the fragment after test/. For instance, if request resource is test/1/ , it will build a Apache2::REST::Handler::test::user containing the user id 1

isAuth

Any method is allowed


Apache2-REST documentation Contained in the Apache2-REST distribution.
package Apache2::REST::Handler::test ;

use  Apache2::REST::Handler::test::user ;

use strict ;
use base qw/Apache2::REST::Handler/  ;

use Apache2::Const qw( 
                       :common :http 
                       );

sub GET{
    my ($self, $req , $resp ) = @_ ;
    
    if ( $req->param('die') ){
        die "This is an error\n" ;
    }
    
    $resp->data()->{'test_mess'} = 'This is a GET test message' ;
    ## It is OK
    return Apache2::Const::HTTP_OK ;
}

sub POST{
    my ($self, $req , $resp ) = @_ ;
    $resp->data()->{'test_mess'} = 'This is a POST test message' ;
    ## It is OK
    return Apache2::Const::HTTP_OK ;
}

sub PUT{
    my ($self, $req , $resp ) = @_ ;
    $resp->data()->{'test_mess'} = 'This is a PUT test message' ;
    ## It is OK
    return Apache2::Const::HTTP_OK ;
}

sub DELETE{
    my ($self, $req , $resp ) = @_ ;
    $resp->data()->{'test_mess'} = 'This is a DELETE test message' ;
    ## It is OK
    return Apache2::Const::HTTP_OK ;
}


sub buildNext{
    my ( $self , $frag , $req ) = @_ ;
    
    my $subh = Apache2::REST::Handler::test::user->new($self) ;
    $subh->{'userid'} = $frag  ;
    return $subh ;
}

sub isAuth{
    my ($self , $method , $req ) = @_ ;
    return 1 ;
}



1;