Grouping interceptors based on URL pattern

41 views
Skip to first unread message

victo...@gmail.com

unread,
Mar 26, 2015, 11:27:27 AM3/26/15
to membrane...@googlegroups.com
Hi, we are using membrane as service proxy to route incoming requests to various backend REST APIs. However, we'd like to know if it's possible to group the interceptors based on incoming URL pattern so that different API could have their own validation without creating new proxy port. e.g.

POST to /api-abc/xxxx validates against abc.json schema
POST to /api-xyz/xxxx validates against xyz.json schema

Thanks in advance.

Thomas Bayer

unread,
Mar 26, 2015, 11:41:12 AM3/26/15
to membrane...@googlegroups.com
Hi,
just setup multiple service proxies that use different paths:

        <serviceProxy port="80">
            <path>/api-abc/</path>
            ...
            <target host="internal" />
        </serviceProxy>



        <serviceProxy port="80">
            <path>/api-xyz/</path>
            ...
            <target host="internal" />
        </serviceProxy>


Cheers,
Thomas

Am 26.03.15 um 16:27 schrieb victo...@gmail.com:
--
You received this message because you are subscribed to the Google Groups "membrane-monitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to membrane-monit...@googlegroups.com.
To post to this group, send email to membrane...@googlegroups.com.
Visit this group at http://groups.google.com/group/membrane-monitor.
For more options, visit https://groups.google.com/d/optout.

victo...@gmail.com

unread,
Mar 26, 2015, 12:48:09 PM3/26/15
to membrane...@googlegroups.com
Thanks! Also, is it possible to set up a shared interceptor tag that can be referenced to use in both /api-abc/ and /api-xyz/ ?

The reason is that we have some common pre-processing work needs to be done for every API, duplicate the <groovy> interceptor scripts in every serviceProxy makes it hard to maintain as API grows. Ideally if an interceptor tag could have an ID, e.g. <groovy id='common'>, and then referenced from each serviceProxy by <groovy ref='common'> to solve the problem. Would it be possible?

Tobias Polley

unread,
Mar 26, 2015, 1:03:29 PM3/26/15
to membrane...@googlegroups.com, victo...@gmail.com
Hi Victor,

recalling from memory, I think it should be possible to do

<spring:beans ...>

<groovy id="common">
... groovy code ...
</groovy>

<router>
  <serviceProxy>
    <path>/b</path>
    ..
    <spring:ref bean="common" />
    ..
  </serviceProxy>

  <serviceProxy>
    <path>/b</path>
    ..
    <spring:ref bean="common" />
    ..
  </serviceProxy>
</router>

</spring:beans>


Best, Tobias

victo...@gmail.com

unread,
Mar 26, 2015, 1:13:09 PM3/26/15
to membrane...@googlegroups.com, victo...@gmail.com
Bravo!! Thanks a ton!!

victo...@gmail.com

unread,
Mar 26, 2015, 1:53:00 PM3/26/15
to membrane...@googlegroups.com, victo...@gmail.com
Is it possible to create a shared <target> as well? Tried but got proxy.xml syntax error...
Reply all
Reply to author
Forward
0 new messages