Alexey Gorbel
Alexey Gorbel

Reputation: 249

Google API Gateway - streaming data in response

I'm using Google Cloud API Gateway in order to have single point of entry to my backed-end services and also for adding api-key security level.

And I have one endpoint which should return data as a stream chunk by chunk(content-type is audio/mpeg). The endpoint is called GET /stream.

I noticed that when I'm hitting this GET /stream endpoint through Google API Gateway the response is returned with a delay of 3-4 seconds and not as a stream, but as a completed response. Also, I noticed that Content-Length header is also returned in the response which makes me think that firstly response downloded on Gateway side only after that was returned to the client who made the request.

Of course, if I'm hitting the original API(without Google API Gateway) I am able to consume stream response immediately without any delays.

Here is how GET /stream is described via swagger 2.0(openAPI) protocol for Google API Gateway config: enter image description here

Does Google API Gateway support streaming responses currently? Any changes that I can do in my swagger 2.0 config for Gateway? Bacisly, any advice on what can I use as an alternative to Google API Gateway to cover my needs + stream supporting?

Any suggestions are appreciated. Thanks in advance!

Upvotes: 2

Views: 1265

Answers (1)

Mabel A.
Mabel A.

Reputation: 2025

There is an ongoing feature request in Github with regards to streaming support in OpenAPI. However, this is with regards to OpenAPI v3, not v2.

If we look at the feature request, there is a workaround to use file format instead of binary. This should be supported since API Gateway uses OAS v2 as stated in the overview,

Google API Gateway supports APIs that are described using the OpenAPI specification, version 2.0.

As additional reference, you may check OpenAPI v2 Data Types.

Upvotes: 0

Related Questions