You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Formatter takes care of handling the various formats into which Grape API responses can be converted. It consists of two parts:
1. Determining from the request what kind of format is desired.
This would first look at any format appended as an extension (i.e. .json or .xml). If no format is appended, it would properly parse and use the HTTP Accept header (including weighted quality values) to determine an array of acceptable formats.
2. Converting data to the desired format.
The middleware would be transparent in Grape, but also usable outside of it. Any data set in the Rack env hash on the key api.response_data should automatically be converted to the desired format (falling back to a to_format call if existing methods aren't in place) and sent along as the response body. A proper content type should also be set based on the used response format.
This should be flexible enough to allow for stranger formats (for example, a PDF or a Zip file response).
The text was updated successfully, but these errors were encountered:
dwmcnelis
pushed a commit
to dwmcnelis/grape
that referenced
this issue
Feb 4, 2013
The Formatter takes care of handling the various formats into which Grape API responses can be converted. It consists of two parts:
1. Determining from the request what kind of format is desired.
This would first look at any format appended as an extension (i.e.
.json
or.xml
). If no format is appended, it would properly parse and use the HTTPAccept
header (including weighted quality values) to determine an array of acceptable formats.2. Converting data to the desired format.
The middleware would be transparent in Grape, but also usable outside of it. Any data set in the Rack
env
hash on the keyapi.response_data
should automatically be converted to the desired format (falling back to ato_format
call if existing methods aren't in place) and sent along as the response body. A proper content type should also be set based on the used response format.This should be flexible enough to allow for stranger formats (for example, a PDF or a Zip file response).
The text was updated successfully, but these errors were encountered: