Add X-API-Options documentation

This commit is contained in:
Christine Dodrill 2015-09-08 16:23:22 -07:00
parent 882b5b1551
commit c050b65bbf
2 changed files with 26 additions and 1 deletions

View File

@ -56,6 +56,31 @@ $ curl http://ponyapi.apps.xeserv.us/season/1/episode/1
} }
``` ```
Bare Replies
------------
As of [882b5b1](https://github.com/Xe/PonyAPI/commit/882b5b155157d3a3c9e329fffcf7ff3fdf64d4ee),
PonyAPI will accept an `X-API-Options` header that when set to `bare` will
return the API replies without the `episode` or `episodes` header.
Functionality is otherwise unchanged, however an error will still be shown if
something goes wrong, and that will parse differently. This API will return
`200` if and **only** if everything went to plan.
An example:
```console
$ curl --header "X-API-Options: bare" http://ponyapi.apps.xeserv.us/last_aired
{
"name": "Do Princesses Dream of Magic Sheep?",
"air_date": 1436628600,
"season": 5,
"episode": 13,
"is_movie": false
}
```
This will also be triggered if you set the query parameter `options` to `bare`.
### `/all` ### `/all`
Returns all information about all episodes. This returns an array of Episode Returns all information about all episodes. This returns an array of Episode

View File

@ -56,7 +56,7 @@ proc `%`(why: string): JsonNode =
template httpReply(code, body: expr): expr = template httpReply(code, body: expr): expr =
## Make things a lot simpler for replies, etc. ## Make things a lot simpler for replies, etc.
if request.headers["X-API-Options"] == "bare": if request.headers["X-API-Options"] == "bare" or @"options" == "bare":
# New "bare" reply format, easier to scrape, etc. # New "bare" reply format, easier to scrape, etc.
resp code, myHeaders, pretty(%body, 4) resp code, myHeaders, pretty(%body, 4)
else: else: