Return response to client from rich plugin

Hi there,

Currently I am working on a POC of integrating Tyk into our framework. Very impressed by the features that are provided out-of-the-box, however the extensibility of the gateway is extremely important for me and left me with some questions.

We use a lot of streaming services, and most of our upstream services are written in Node. I’ve set up a rich NodeJS plugin following the docs using gRPC which works fine. It allows me to import a custom npm module that we use for client-server communication on TCP with duplex-streams. In this usecase, however, I would like to pipe the response of my custom client into a HTTP response object directly back to the client instead of proxying it to a upstream service.

I’ve looked around and found Transforming Resources, however I am not sure how to “just return the object instead of having Tyk do it” with the available tools, and I was wondering how exactly I should approach this.

tldr; Proxy to upstream service myself using rich plugin, would like to send response directly back to client instead of continuing the pipeline.

Cheers and thanks in advance!

Hi, that’s a very interesting use case.

Have you tried using ReturnOverrides?

He, thanks for the prompt reply!

I found the docs regarding ReturnOverrides. I’ve played around with it, and it does seem to stop the request-flow and return directly back to the client. However I can only return response codes, headers and/or error messages.

Checking the contents of obj.request.return_overrides there seems to be nothing regarding the res.body, am I missing something obvious here?

cheers

The value to set is the error, ReturnOverrides were originally designed to only return errors.