I have a following REST end-point in my Spring Boot Application.
/employees
This returns following response.
{
    "id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "department": "IT",
    "salary": "$5000"
    ...
    //There are more here
}
Now, I need to have this end-point used by two different clients. But the need to know only part information from this end-point.
So for client1, the output would be as below:
{
    "id" : 1,
    "firstName" : "John",
    "lastName" : "Doe"
}
And for the other client(client2), the response should be.
{
    "id" : 1,
    "department": "IT",
    "salary": "$5000"
}
How can I approach this problem is best possible way?
Client1 and Client2 would be distinguished by their authentication details. Maybe a configuration which specifies how the response entity needs to be filtered. That way, whenever I am configuring a new client, I can create a new configuration for the client and that takes care of the response filtering.
 
     
     
     
    