camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daveharris <d...@harris.org.nz>
Subject camel-http: Multiple Request Paramaters
Date Thu, 28 Jul 2011 02:43:57 GMT
Hi,
I am writing a route which sends a HTTP GET request with a bunch of request
parameters.

Looking at the documentation, the way to do this is via:
from("direct:start")
  .setHeader(Exchange.HTTP_QUERY, constant("order=123&detail=short"))
  .to("http://oldhost");

This is fine, but I was hoping for a cleaner way of doing it  -where I don't
have to handle escaping and &s.
I've been talking to @Blair and he suggested passing in a map to
Exchange.HTTP_QUERY but that didn't work.

My route defintion turns into a somewhat ugly-looking:
from("...")
.setHeader(Exchange.HTTP_QUERY, 
  constant("app=").append(header(APPLICATION))
  .append("&from=").append(header(FROM))
  .append("&to=").append(header(TO))
  .append("&msg=").append(header(MESSAGE))
)
.to("http://localhost/service")

To produce a HTTP get request of
http://localhost:3000/service?app=test&from=a&to=b&msg=hi

Is this is the only/best way to do it?  Just checking that there isn't some
shortcut which I can use instead.

The above *works* perfectly well, just being pedantic...

Thanks,
Dave

--
View this message in context: http://camel.465427.n5.nabble.com/camel-http-Multiple-Request-Paramaters-tp4641050p4641050.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message