Overview

HTTP verbs

Parrot-REST application is a simple application that exposes to RESTs endpoints. One POST endpoint to listen and remember REST calls. The second endpoint is intended to talk or reproduce what was posted in the listen phase. . This application might be interesting in semi-integrated testing environments.

Verb Usage

GET

Used to retrieve a resource

POST

Used to create a new resource

DELETE

Used to delete a resource

Parrot-REST tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP status codes.

Status code Usage

200 OK

The request completed successfully

201 Created

A new resource has been created successfully. The resource’s URI is available from the response’s Location header

204 No Content

An update to an existing resource has been applied successfully

400 Bad Request

The request was malformed. The response body will include an error providing further information

404 Not Found

The requested resource did not exist

Resources

Health

The health provides the ability to validate that the parrot is up and running.

Accessing the listen

A GET request is used to access the health

Example response

HTTP/1.1 200 OK
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 57

I'm a healthy parrot, do you have sunflower seeds for me?

Example request

GET /health HTTP/1.1
Host: localhost:8080

CURL request

$ curl 'http://localhost:8080/health' -i

Listen

The listen provides the ability to create responses that can be retrieved by the talk resource.

Accessing the listen

A GET request is used to access the listen

Example response

HTTP/1.1 200 OK
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 2

OK

Example request

POST /listen HTTP/1.1
Content-Type: application/hal+json
Host: localhost:8080
Content-Length: 110

{
  "appContext" : "appContext",
  "url" : "path",
  "response" : "{\"id\": 1, \"name\": \"Test response\"}"
}

CURL request

$ curl 'http://localhost:8080/listen' -i -X POST -H 'Content-Type: application/hal+json' -d '{
  "appContext" : "appContext",
  "url" : "path",
  "response" : "{\"id\": 1, \"name\": \"Test response\"}"
}'

Talk

The talk provides the ability to echo responses that can be posted by the listen resource.

Accessing the talk

A POST request is used to access the talk

Example response

HTTP/1.1 200 OK
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 42

{
  "id" : 1,
  "name" : "Test response"
}

Example request

GET /talk/appContext/path HTTP/1.1
Host: localhost:8080

CURL request

$ curl 'http://localhost:8080/talk/appContext/path' -i

Forget

The forget provides the ability to remove existing responses which were posted by the listen resource.

Accessing the forget

A DLETE request is used to access the forget

Forget an existing resource

Example response

HTTP/1.1 200 OK
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 2

OK

Example request

DELETE /forget/appContext/path HTTP/1.1
Host: localhost:8080

CURL request

$ curl 'http://localhost:8080/forget/appContext/path' -i -X DELETE

Forget a non-existing resource

Example response

HTTP/1.1 204 No Content
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 10

NO_CONTENT

Example request

DELETE /forget/appContext/pathDoesNotExist HTTP/1.1
Host: localhost:8080

CURL request

$ curl 'http://localhost:8080/forget/appContext/pathDoesNotExist' -i -X DELETE