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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -