Skip to content

Latest commit

 

History

History
75 lines (42 loc) · 2.09 KB

8. Headers.md

File metadata and controls

75 lines (42 loc) · 2.09 KB

FORMAT: X-1A

Headers API

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 given method at a given resource.
  • On the resource level it represents headers that are always sent and received with every request or response made at a given resource.

API Blueprint

Group Messages

Group of all messages-related resources.

My Message [/message]

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
    

Retrieve a Message [GET]

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!" }
      

Update a Message [PUT]

  • 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