Specifying the Google Cloud Endpoints Response Protocol

Can I specify the Response output protocol when creating a method with cloud endpoints?

I would like to use protobuf instead of json.

+4
source share
1 answer

You can simply specify a different Accept tag in your HTTP request that describes the mime type for the serialization you want. Here's how it works in the Python SDK for Cloud Endpoints, at least.

For example, if you specify the Accept application/json header, Cloud Endpoints should automatically use the built-in JSON converter to serialize the response. It so happens that JSON-mapper is used if no other serialization is specified.

The mime type for responses encoded by protobuf is semi-standardized as application/protobuf (see https://tools.ietf.org/html/draft-rfernando-protocol-buffers-00 ). I would use this in your Accept header and see if you get the desired answer.

0
source

Source: https://habr.com/ru/post/1498349/


All Articles