App-Presto

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

SYNOPSIS

    Invoke from the shell:

            bash$ presto http://my-server.com
            

    Very basic usage:

            http://my-server.com> GET /product/1.json
            {"id":1,"name":"My Product"}
    
            http://my-server.com> HEAD /product/1.json
            HTTP/1.1 200 OK
            Connection: close
            Date: Thu, 28 Jun 2012 21:05:33 GMT
            Content-Length: 0
            Content-Type: application/json
            Client-Date: Thu, 28 Jun 2012 21:05:44 GMT
            Client-Response-Num: 1

DESCRIPTION

    App::Presto provides a command-line interface (CLI) for RESTful web
    services. When looking for a way to interact with RESTful services
    answers typically point to some horrible GUI or (on the complete
    opposite end of the spectrum) just using curl directly on the
    command-line. This tool attempts to find some sort of middle ground by
    providing a quasi-DSL for interacting with a RESTful service in an
    interactive way.

FEATURES

 Basic HTTP methods

    All HTTP methods are implemented as commands in presto. The URL that is
    given is appended to the endpoint specified when presto is invoked as
    shown in the SYNOPSIS above.

 Request Building

    If the endpoint contains a * character the URL fragment specified in
    the GET/POST/etc command is inserted at that point. This allows you to
    do things like auto-append a file extension to all URLs. For instance:

            bash$ presto http://my-server.com*.json
            http://my-server.com> GET /product/1

    In this case, the full URL would be
    http://my-server.com/product/1.json. If no * is found in the URL, the
    URL fragment is simply appended at the end of the endpoint.

    All arguments after the first will be treated as query parameters (for
    GET/HEAD/DELETE requests) or request content (for POST/PUT requests).
    For instance:

            http://my-server.com> GET /products limit=10 offset=20
      # request goes to http://my-sever.com/products?limit=10&offset=20
    
            http://my-server.com> POST /products '{"name":"A New Product"}'
      # request goes to http://my-sever.com/products with the body as specified

    You can also specify additional headers you would like included in the
    request:

            # the ":" is optional
            http://my-server.com> header Accept: application/json
    
            # shortcut for "header Content-Type application/json"
            http://my-server.com> type application/json
    
            # shortcut for "header Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
            http://my-server.com> authorization Aladdin 'open sesame'
    
            # view all headers
            http://my-server.com> headers
    
            # view specific header
            http://my-server.com> header Authorization
    
            # clear all headers
            http://my-server.com> headers --clear
    
            # unset specific header
            http://my-server.com> header --unset Authorization

    If you are creating form URL-encoded data, a shortcut has been made to
    avoid having to manually URL-encode everything manually:

            http://my-server.com> form foo=bar baz=1,2,3
    
            # outputs
            foo=bar&baz=1%2C2%2C3

 Response Handling

    By default, presto will just dump the response body to the screen after
    a request is completed. There are additional options, however:

            # dump full request/response to the screen (exactly as transmitted over the wire)
            http://my-server.com> config verbose 1
    
            # parse the response according to the content-type and use
            # Data::Dumper to display it
            http://my-server.com> config deserialize_response 1
    
            # use something other than Data::Dumper to dump a parsed
            # response body
            http://my-server.com> config pretty_printer JSON
            http://my-server.com> config pretty_printer Data::Dump
    



( run in 1.606 second using v1.01-cache-2.11-cpan-b16cb0d3907 )