Reputation: 970
I'm attempting to add an authorisation header to my camel rest route. Here's the route:
restConfiguration().producerComponent("http4").host(env.getProperty("my.rest.host"));
from(env.getProperty("in.route"))
.to(env.getProperty("rest.endpoint.path"))
I'm familiar with the 'non-camel' procedure, for example using RestTemplate where you can do something like setHeader("Authorisation", "Bearer myJWT..."). I was expecting there to be something equally as straightforward for camel. But my search so far has not prevailed! Can anybody give me a hint?
Thanks :)
Upvotes: 0
Views: 2256
Reputation: 5703
Use exchage and update header
from(env.getProperty("in.route")).process(new Processor {
public void process(Exchange exchange) throws Exception {
//you token logic
String token = "--token logic-------"
exchange.getIn().setHeader("Authorization", token)
}
}).to(env.getProperty("rest.endpoint.path"))
Upvotes: 1