Adding a GET parameter via an Interceptor

29 views
Skip to first unread message

Damian Sobieralski

unread,
Jun 29, 2015, 5:33:12 PM6/29/15
to membrane...@googlegroups.com
I'm trying to add a get parameter to the back end request.  But I'm not finding an examples of how to do this. HELP! :)

Here is what I have:

        <serviceProxy>
...
                    <target host="backend-server.com" port="443">
                        <ssl />
                    </target>
        </serviceProxy>

I have an interceptor (let's call it MyAwesomeInterceptor). What I need to do is add a GET parameter to the backend request call. However, this is not a static content thing.  In my interceptor I am looking for a specific header and based on a lookup of that header value is the value I would like the get parameter to be.

Let's look at it this way:

MyHeader : bob

I need get parameter mygetparm = red

so the final call will be something like backend-server.com...?mygetparm = red

MyHeader: fred

I need get parameter mygetparm = blue

so the final call will be something like backend-server.com...?mygetparm = blue

MyAwesomeInterceptor I already have working to handle the headers. There is a much more complicated logic in this Interceptor than I explained here. But I simplified it to illustrate the thing that I need help with.  If I can just find a way to dynamically add a get parameter and I'm home free.

Any hints on how I would do this?

- Damian

Thomas Bayer

unread,
Jun 30, 2015, 2:16:47 AM6/30/15
to membrane...@googlegroups.com
Hi,
first get the URI where the request will be send to like:

String uri = exchange.getDestinations().get(0);

then set the new URI as destination:

exchange.getDestinations().set(0, uri + "&param=x");

Hope that solves it.

Cheers,
Thomas

Am 29.06.15 um 23:33 schrieb 'Damian Sobieralski' via membrane-monitor:
--
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.

Damian Sobieralski

unread,
Jun 30, 2015, 11:58:25 AM6/30/15
to membrane...@googlegroups.com
That worked quite well.

Thanks, Thomas!


Reply all
Reply to author
Forward
0 new messages