What HTTP header should I use for specifying stylistic properties of an HTTP response, specifically the case of keys in a JSON object? A note: I am developing a REST API where I would like clients to provide an expected case, for example camelCase
or snake_case
.
When camelCase
is specified a response would look like:
{
"peopleUrl": "…",
"postsUrl": "…"
}
When snake_case
is specified a response would look like:
{
"people_url": "…",
"posts_url": "…"
}
The headers I’ve been looking at are Expect
and Prefer
. Expect
is described as mandatory configurations a server must comply with or error, and Prefer
is described as optional configurations. The specific syntax I was looking at is:
Expect: case=camel
or:
Prefer: case=camel
Currently, I’m feeling like Expect
is the best because it requires the configuration. However, while in RFC 2616 an extension mechanism for Expect
is provided, however in RFC 7231 this extension mechanism was removed and only the 100-continue
field is allowed (scroll to the next page to see the note providing the warrant). The Prefer
header was specified in RFC 7240 and does appear to have an extension mechanism.
Which header is best for this configuration option? Am I looking in the wrong direction with Expect
and Prefer
?