- Change Summary:
-
* Switched to returning error codes instead of WebAPIResponseErrors where possible, so that we can do the automatic mimetype stuff. * Fixed mimetype handling with our provided pagination and error responses. * Added a build_response_args() function that a resource must use when populating arguments for a custom WebAPIResponse result. Long-term, we should move away from returning WebAPIResponses outside of the core WebAPIResource code.
- Testing Done:
-
+ Unit tests pass.
+ + Tested with my Review Board change, which thoroughly tests all this functionality.
+ Also verified by hand.
Add support for resource-specific mimetypes.
Review Request #2750 — Created Dec. 17, 2011 and submitted
Add support for resource-specific mimetypes. A common method for REST services is to have payloads returned with resource-specific mimetypes. These can help to identify the format of a payload (useful for automatic bindings) without having to inspect the URI. This adds support for easily telling a resource to return such mimetypes. If mimetype_vendor is specified, WebAPIResource can populate the accepted mimetypes list with some vendor/resource-specific mimetypes that will be used by default for any responses. When there's a vendor mimetype, the resources will use the resource names for the mimetypes, but these can be overridden using mimetype_list_resource_name and mimetype_item_resource_name.
Unit tests pass. Tested with my Review Board change, which thoroughly tests all this functionality. Also verified by hand.