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);
}
Camel makes extensive use of URIs to allow you to refer to Endpoints. This endpoint is created by the Kafka component. The URI contains endpoint configurations as context-path and query parameters.
Camel uses a Java Domain Specific Language or DSL for creating Enterprise Integration Patterns or Routes in a variety of domain-specific languages (DSL) as listed below: Java DSL - A Java based DSL using the fluent builder style.
camel-http's bridgeEndpoint=true If a route consumes from restlet/servlet, then later calls a different web endpoint (using the “http:” or “https:” components), you have to include the “? bridgeEndpoint=true” query param on that call's URI.
Turns out that this is really easy:
public Customer customerDetail(Exchange exchange){
String id = exchange.getIn().getHeader("id").toString();
return getCustomer(id);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With