Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Moved code example into tabs

...

Code Block
  from("spark-rest:get:/hello/*/to/*")
    .transform().simple("Bye big ${header.splat[1]} from ${header.splat[0]}");

Rest DSL

Apache Camel provides a new Rest DSL that allow to define the REST services in a nice REST style. For example we can define a REST hello service in Java DSL as shown below:

Tabs Container
idRestDslTabs
titleRest DSL
directionhorizontal
Tabs Page
idRestDslTabsJava
titleJava
Code Block
  return new RouteBuilder() {
      @Override
      public void configure() throws Exception {
            rest("/hello/{me}").get()
                .route().transform().simple("Bye ${header.me}");
        }
    };

 

...

Tabs Page
idRestDslTabsXml
titleXML
Code Block
xml
xml
  <camelContext xmlns="http://camel.apache.org/schema/spring">
    <rest uri="/hello/{me}">
      <get>
        <route>
          <transform>
            <simple>Bye ${header.me}</simple>
          </transform>
        </route>
      </get>
    </rest>
  </camelContext>

See more details at the Rest DSL.

...