using membrane to expose subset of APIs

38 views
Skip to first unread message

nazir...@gmail.com

unread,
Jun 13, 2016, 12:09:36 PM6/13/16
to membrane-monitor
Hi,

I have a closed, backend SOAP API i need to expose to a customer and will be front-ending it with Membrane. The API itself is very extensive, and the customer only really needs to access 1 or 2 api calls. Is it possible to only expose the API calls this particular customer requires? If it is, how would I go about doing it?

If not possible, is it possible to blacklist/whitelist based upon the request call? For example, if i only want the user to access calls1-3, then any request for anything outside of calls1-3 will be rejected by membrane.




Thanks,

Adeel

Till Born

unread,
Jul 22, 2016, 7:23:56 AM7/22/16
to membrane-monitor, nazir...@gmail.com
Hello,
sorry for the late response. For a whitelist/blacklist like behaviour you could setup membrane like this:

<router>

   
<serviceProxy port="2000">
     
<request>
         
<groovy>
            def server = "http://my.api.server.com";
            Set
&lt;String&gt; whiteList = [
            "/my/api/call",
            "/my/api/call2",
            "/my/api/call3"
            ]

            if(whiteList.contains(exc.getRequestURI())){
               exc.getDestinations().clear();
               exc.getDestinations().add(server + exc.getOriginalRequestUri());
               return CONTINUE;
            }

            exc.setResponse(Response.notFound().build());
            return RETURN;
         
</groovy>
     
</request>
   
</serviceProxy>
 
 
</router>
This configuration uses the groovy interceptor to accomplish what you want to do. You can specify a whitelist of paths that can be accessed. You have to replace the "server" variable with your api server. 
Hope i could help.

Greetings,
Till

Reply all
Reply to author
Forward
0 new messages