Respond With
Respond to multiple request types easily and conveniently
If we need to render a template to html render("template.slang")
works nicely. A lot of times we want to respond with json, xml, text or something else. In those cases, we can use respond_with
.
Amber will use 2 methods to determine which response type to use:
The
accepts
headerA url extension
These are the currently supported response types:
Usage
If you do not specify a response type with the accepts
header or using the dot notation in the url, you will get the first defined response type. In this example you would get the html
response.
Last updated