Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache-camel: http query string parameter as headers?

I'm new to camel and prefer using Spring DSL for route definition. Now I find it's confusing, that http query string parameter are named and handled as headers, what they aren't. Is this an architectural bug in camel?

like image 548
Jundl Avatar asked Mar 11 '23 18:03

Jundl


1 Answers

Incoming http requests will be added as headers on the exchange with the same name as the query parameter.

Below example is from camel documentation

For example, given a client request with the URL, http://myserver/myserver?orderid=123, the exchange will contain a header named orderid with the value 123.

You can set the query parameters for other HTTP calls you make by setting by CamelHttpQuery header. Exchange.HTTP_QUERY is the static constant for string CamelHttpQuery

Eg:

from("jetty://0.0.0.0:8080/test")
    .setHeader(Exchange.HTTP_QUERY, simple("?param1=${header.param1}")
    .to("http://external-url/test")
like image 91
usha Avatar answered Apr 01 '23 01:04

usha