Reputation: 2586
How can i access PathVariables in the Apache Camel Rest module?
I defined a route like this (following "using base path" from the documentation):
rest("/customers/")
.get("/{id}").to("direct:customerDetail")
How can i get a hold on the {id}
-Parameter in the following route?
Basically i would like to know what camel offers instead of @PathVariable
(see following example)
@RequestMapping(value="/customers/{id}", method = RequestMethod.GET)
public Customer customerDetail(@PathVariable String cId) {
return getCustomer(cId);
}
Upvotes: 5
Views: 9891
Reputation: 11
${header.id}
works.
try using log:
.log(LoggingLevel.INFO, "${header.id}");
Upvotes: 0
Reputation: 2586
Turns out that this is really easy:
public Customer customerDetail(Exchange exchange){
String id = exchange.getIn().getHeader("id").toString();
return getCustomer(id);
}
Upvotes: 7