I have read in this book called: Kong: The king of API Gateways that says you can compose and transform API requests and responses. It suggests that you can combine many responses into a single response so a client only needs to make a single call instead of having to make many more to have the data for a single page. This would be a great benefit to simplification of client calls.

The problem is that the book doesn't actually tell you how to do this using kong

I tried using the request and response transformers, but these only make changes to the single request or response.

1 Answers

-1
chandra Kalita On
It should be pretty easy
You can actually use Java Aggregation Pattern as below.Assuming you have below Response from 3 calls:
1. public class EmployeeResponse extends Response{..};
2. public class SocialSecurityNumberResponse extends Response{..};
3. public class EmployeeSalaryResponse extends Response{..} ;

Following composite Response can be constructed:
public class CompositeEmployeeResponse extends Response{
private EmployeeResponse employeeResponse;
private SocialSecurityNumberResponse socialSecurityNumberResponse;
private EmployeeSalaryResponse employeeSalaryResponse;

/*....getters/setters....**/
}