We have a Person class and in our Spring boot Controller for the Person class we have a few functions that have a path that starts with
/person/{id}
However, we want to reuse all those functions for other paths where a Person Object can be retrieved like for example:
/payment/{id}/payer
/payment/{id}/receiver
Otherwise, we need to write the functionality for GetMapping(path = "[...]/first-name") a lot of times. Is there a way to achieve this?
To clarify: For these three URL's it should execute:
// person = the Person Object that would normally be returned
return person.getFirstName();
You can try this