I it possible to specify the output protocol of the Response when creating a method with cloud endpoints?
I would like to use a protobuf instead of json.
I it possible to specify the output protocol of the Response when creating a method with cloud endpoints?
I would like to use a protobuf instead of json.
You can simply specify a different Accept
header in your HTTP request, describing the mime type for the serialization you want. This is how it works in the Python SDK for Cloud Endpoints, at least.
For instance, if you specify an Accept
header of application/json
, Cloud Endpoints should automatically use its builtin JSON mapper to serialize the response. It just so happens that the JSON mapper is used if no other serialization is specified.
The mime type for protobuf-encoded responses is semi-standardized as application/protobuf
(see: https://datatracker.ietf.org/doc/html/draft-rfernando-protocol-buffers-00). I'd use that in your Accept
header and see if you get a desirable response.