In HTTP requests (and other requests or messages) you usually get a payload and a bunch of headers. In Camel you can find the payload in the “body” variable like this:
public class MyRoute extends RouteBuilder { @Override public void configure() throws Exception { from("timer:mytimer?repeatCount=1") .to("https://www.google.com") .log("${body}"); } }
So, how do you access the headers? There is another variable for this called “in” and it can be used like this:
public class MyRoute extends RouteBuilder { @Override public void configure() throws Exception { from("timer:mytimer?repeatCount=1") .to("https://www.google.com") .log("${in.headers}") // Log all incoming headers .log("${in.headers.Content-Type}"); // Log a specific header } }
Tested on Ubuntu 20.04.4 LTS, Apache Camel 3.20, Minikube v1.29.0 (Camel-K) and Java 1.8.0_352
0 Comments.