FORMAT: X-1A
Let's discuss HTTP Headers - the metadata sent (or received) with our responses (or requests). As discussed in the Responses example a payload (request or response) may include the headers
entry to specify the headers to be sent (or received) with it.
In addition to this you can specify headers on both the action
and resource
levels.
- On the
action
level it represents headers that are always sent and received with every request or response made with a givenmethod
at a givenresource
. - On the
resource
level it represents headers that are always sent and received with every request or response made at a givenresource
.
Group of all messages-related resources.
Let's define a header that is always sent or received with any request made on this resource in addition to what is specified in subsequent actions and their payloads (requests and responses).
-
Headers
X-Resource-Level-Header: 40
Here we will define a header that is always sent or received with any request on this resource using the GET
HTTP request method.
-
Headers
X-Method-Level-Header: 41
-
Request Plain Text Message
-
Headers
Accept: text/plain
-
-
Response 200 (text/plain)
-
Headers
X-My-Message-Header: 42
-
Body
Hello World!
-
-
Request JSON Message
-
Headers
Accept: application/json
-
-
Response 200 (application/json)
-
Headers
X-My-Message-Header: 42
-
Body
{ "message": "Hello World!" }
-
-
Request Update Plain Text Message (text/plain)
All your base are belong to us.
-
Request Update JSON Message (application/json)
{ "message": "All your base are belong to us." }
-
Response 204