Accent v0.2.0 Accent.Plug.Response
Transforms the keys of an HTTP response to the case requested by the client.
A client can request what case the keys are formatted in by passing the case
as a header in the request. By default the header key is Accent. If the
client does not request a case or requests an unsupported case then no
conversion will happen. By default the supported cases are camel, pascal
and snake.
Options
:header- the HTTP header used to determine the case to convert the response body to before sending the response (default:Accent):json_encoder- module used to encode JSON. The module is expected to define aencode!/1function for encoding the response body as JSON. (required):json_decoder- module used to decode JSON. The module is expected to define adecode!/1function for decoding JSON into a map. (required):supported_cases- map that defines what cases a client can request. By defaultcamel,pascalandsnakeare supported.
Examples
plug Accent.Plug.Response, header: "x-accent",
supported_cases: %{"pascal" => Accent.Transformer.PascalCase},
json_encoder: Poison,
json_decoder: Poison