RESTful API communication between multiple web servers

angularjsapirest

I'm trying to understand RESTful communication, but I still have a few doubts.

Architecture
I have a main web application (on the right side of the Architecture) made in AngularJS, which shows data coming from multiple web servers containing other applications or databases (on the left side). Some of these applications don't have a REST api and some do, so I imagined putting a REST api interface between those applications and the AngularJS web app would facilitate the work.

My problem is, i don't properly know those REST api from the applications on the left side.

My current "solution" for this, is to register each application, including its endpoints, resources, etc. Assuming some of those endpoints use SSE (Server Sent Events) and some others just display specific data, I though of something like this:

Resources

I separate the endpoints from the ones offering SSE so that I can apply long lopping in angularjs, as well as per methods, in order to use only the ones related to GET to obtain data, and PUT to update, and so on.

My questions is, does this make sense at all? Is this the right way to do it?

I'm aware, that if some of those applications already have a REST api , I could access it directly using $http or ngResource in AngularJS. But what if I don't entirely know this REST api, or what if it hasn't even been done yet ?

Thank you!

Best Answer

Since you have a lot of unknowns regarding the down stream services you are interacting with it might make sense to create your own REST services that live along side your AngularJS application. Each of your endpoints could then delegate to the downstream services and aggregate the responses as appropriate. This would also prevent you from having to make changes to the UI layer if you add/change downstream service providers.

If you created a Java based backend something like Apache camel could be benefitial: http://camel.apache.org/