Search code examples
routesapache-camelroute-parameters

How to prevent Apache Camel delegating route parameters to called route url


I'm trying to get in touch with Apache Camel, but it's behaviour is so far confusing.

For example, I'm using platformHttp and declare a route under which my endpoint should be available.

from(platformHttp("/api/test"))
     .to("https:google.com?bridgeEndpoint=true")
     .setBody(simple("${body}"));

Calling it will call the sub-route https://google.com/api/test instead of https://google.com

Why is that and how would I prevent Apache Camel from taking the route and appending it to the called route in my .to() ?


Solution

  • To prevent the HTTP exchange headers (I.e ones with names prefixed with CamelHttp) being propagated from the platform-http endpoint to the http endpoint, you can remove them like this.

    from(platformHttp("/api/test"))
         .removeHeaders("CamelHttp*")
         .to("https:google.com?bridgeEndpoint=true")
         .setBody(simple("${body}"));
    

    There's an FAQ article for this topic on the Camel website:

    https://camel.apache.org/manual/faq/how-to-remove-the-http-protocol-headers-in-the-camel-message.html