John D. Fa'atuai > REST-Resource-0.5.2.4 > /parts.cgi

Download:
REST-Resource-0.5.2.4.tar.gz

Annotate this POD

View/Report Bugs
Source  

NAME ^

    /parts.cgi          -- Sample REST::Resource CGI

SYNOPSIS ^

    http://server/pathto/parts.cgi      -- Get the parts list

DESCRIPTION ^

    This script demonstrates how to derive from REST::Resource and add
    specialized HTTP method handlers.

AUTHOR ^

    frotz@acm.org

METHODS - main:: ^

main()

USAGE:

    &main();
    exit( 0 );

DESCRIPTION:

    This is the top-level method for this CGI script.

METHODS - Restful::Parts::Resource ^

new()

USAGE:

    my( $this ) = new Restful::Parts::Resource();
    $this->handle_request();
                ## OR
    $this->run();

DESCRIPTION:

    This constructor registers all handlers for this RESTful resource.

dispatcher()

USAGE:

    $this->method( "GET",    \&Restful::Parts::Resource::dispatcher, "Returns a structured list of parts." );
    $this->method( "PUT",    \&Restful::Parts::Resource::dispatcher, "Create an existing part." );
    $this->method( "POST",   \&Restful::Parts::Resource::dispatcher, "Modify an existing part." );
    $this->method( "DELETE", \&Restful::Parts::Resource::dispatcher, "Remove an existing part." );
    $this->method( "HEAD",   \&Restful::Parts::Resource::dispatcher, "Discover this resource's API." );
    $this->method( "api",    \&Restful::Parts::Resource::dispatcher, "Discover this resource's API." );

DESCRIPTION:

    This method interrogates the request and routes to the appropriate
    derived class method.

parts_list() - GET

USAGE:

    my( $status, \%data ) = $this->parts_list( $request_interface_instance );

DESCRIPTION:

    This method retrieves the number of parts currently known by this
    RESTful resource.

PATH INFO SEMANTICS:

    None        -- Return the list of all parts
        200     -- $data->{count} contains the number of known parts.
                   $data->{parts} is a hashref containing all known parts.

    /part/$part -- Return JUST the information for part => $part.
        200     -- $data->{part} is the requested part.
                   $data->{desc} is the requested part description.
        404     -- Unable to read description for part => $part.

create_part() - PUT

USAGE:

    my( $status, $data ) = $this->create_part( $request_interface_instance );

DESCRIPTION:

    This method creates a new part that will be known by this RESTful
    resource.

STATUS CODES:

    201         -- Part created successfully.
    302         -- Unable to create part.
    412         -- Required data not provided.

modify_part() - PUT

USAGE:

    my( $status, $data ) = $this->modify_part( $request_interface_instance );

DESCRIPTION:

    This method modifies an existing part known by this RESTful
    resource.

STATUS CODES:

    200         -- Part modified successfully.
    304         -- Unable to modify part.
    404         -- No part specified.

delete_part() - DELETE

USAGE:

    my( $status, $data ) = $this->delete_part( $request_interface_instance );

DESCRIPTION:

    This method removes an existing part known by this RESTful
    resource.

STATUS CODES:

    200         -- Part removed successfully.
    404         -- Unable to remove part.

format_html()

USAGE:

    print $this->format_html( $request_interface_instance, $status, $data );

DESCRIPTION:

    Format $data such that if $data->{parts} exists, then we want a sorted table of parts.
    Otherwise, we assume we are just dealing with a specific part.

_read() - PRIVATE

USAGE:

    my( $content )      = $this->_read( $file );

DESCRIPTION:

    This method will read the file and return the contents to the
    caller or fail with an exception.

_write() - PRIVATE

USAGE:

    $this->_write( $file, $content );

DESCRIPTION:

    This method will write $content to $file or fail with an
    exception.

_interrogate_request() - PRIVATE

USAGE:

    my( $data ) = $this->_interrogate_request( $request_interface_instance );

DESCRIPTION:

    This method will attempt to pull all request parameters from the
    various places likely to pass them.

_parts_list_select() PRIVATE

USAGE:

    print $this->_parts_list_select( $field_name );

DESCRIPTION:

    This method will generate a prepopulated select list named $name
    and return it to the caller.
syntax highlighting: