java - REST: Using a second service to finally answer a request? -
having 2 independent rest (micro) services 1 service borrows functionality of second transparently answering resource request, standards / specs in place?
example:
service addresses: - /addresses/id -> {address-json given id} service persons: - /persons/id -> {person small description} - /persons/id/homeaddress -> {address-json persons home address or 404}
implementing persons/id/homeaddress functionality looks like:
homeaddress(int personid) { person person = getperson(personid); optional<addressreference> addressreference = person.gethomeaddress(); if(addressreference.ispresent()) return get("/addresses/" + addressreference.get()); else throw new notfoundexception(); }
any standard or practical advice, how best handle different http response codes of get(...) part?
[update]
both services totally independent. addresses might service being used in total isolation allowing manage different address entities in existence including shipping addresses etc. referenced different datasets stored in different databases , might evolve independently.
the goal integrate kind of logical reuse of functionality of distinct second service realize processing of request. 1 might see workflow of requests being transparent original client.
Comments
Post a Comment