Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
    <rest>
      <get uri="/customers/{id}">
        <to uri="direct:customerDetail"/>
      </get>
      <get uri="/customers/{id}/orders">
        <to uri="direct:customerOrders"/>
      </get>
      <post uri="/customers/neworder">
        <to uri="direct:customerNewOrder"/>
      </post>
    </rest>

Using Dynamic To

Available as of Camel 2.16

The Rest DSL supports the new .toD <toD> as dynamic to in the rest-dsl. For example to call a bean with the id from the rest url, you can do

Code Block
xml
xml
 public void configure() throws Exception {
   rest("/say")
     .get("/hello/{language}").toD("bean:hello?la=${header.language}");
}

And in XML DSL

Code Block
xml
xml
<rest uri="/say">
  <get uri="/hello//{language}">
    <toD uri="bean:hello?la=${header.language}"/>
  </get>
<rest>

 

See more details at Message Endpoint about the dynamic to, and what syntax it supports. By default it uses the Simple language, but it has more power than so.

Embedding Camel routes

Each of the rest service becomes a Camel route, so in the first example we have 2 x get and 1 x post REST service, which each become a Camel route. And we have 2 regular Camel routes, meaning we have 3 + 2 = 5 routes in total. 

...