ExpressGateway / express-gateway

A microservices API Gateway built on top of Express.js
https://www.express-gateway.io
Apache License 2.0
2.97k stars 344 forks source link

Expose response body to response transformer policy. #1012

Closed 73rhodes closed 3 years ago

73rhodes commented 3 years ago

Hello maintainers and thanks for taking the time to review this. We needed to be able to transform responses not only by adding and removing properties on the response body, but also by using properties in the original response body and modifying their original values. A simple way to do that was exposing the original response body in the egContext so that it can be referenced in the expressions of the responseTransformer actions. I also wanted to be able to set nested properties in the response body.

If you think this runs against the design intent of the original req/res modifier, it would be greatly appreciated if you could suggest an alternative approach to modifying properties within the original response body.

Note that this change only exposes the response body only, and not the request body, but it could be updated to support both if wanted.

XVincentX commented 3 years ago

Hey @73rhodes, thank you very much for the PR.

Unfortunately the project has been halted and I currently have nor the time nor plans to resume it.

The time to resemble the context of all this would be significant and I do prefer to leave the project as it is right now.

I would suggest you to keep your fork and go from there.