Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jaggery (WS02) endpoint reference/dynamic endpoint

I'm currently developing an application in Jaggery which I deploy on their API manager.

From the Jaggery back end I'm calling a SOAP webservice using the method documented here, which specifies:

<%      
var url = 'http://jaggeryjs.org/apidocs/resources/home.jag'; 
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader("user" , "madhuka");
xhr.send();

print("ReadyState : "+xhr.readyState);
print("<br>ResponseStatus : "+xhr.status);
print("<br>ResponseText : "+xhr.responseText);
%>

I have everything up and working fine, however I'd like to remove the hard-coded URL and replace it with some sort of URL lookup, based on environment.

What is the correct way of doing this? Can I specify an endpoint in API manager and refer to it? Or perhaps use an EPR file. I've had little luck with the Jaggery documentation in this sense.

like image 660
Continuity8 Avatar asked Jan 18 '16 02:01

Continuity8


1 Answers

I have seen many jaggery apps developed for WSO2 products. The practice followed in them is to have a config file in json format. You can have a method to read it and get necessary values by passing the attribute name.

You can either have a config file for each environment and pack the correct one with the app or have a single config file with endpoints for each environment. If you are going to maintain a single config file, you have to dynamically construct the attribute name and read its value. To do that also, you need to maintain which environment it is. Therefore I recommend to use a config file for each environment and bundle the correct file for the environment.

like image 180
Amila Maharachchi Avatar answered Nov 09 '22 11:11

Amila Maharachchi