Versions Compared

Key

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

...

Tip

The REST DSL will take care of duplicate path separators when using path prefixes. In the example above the rest path prefix ends with a slash ( / ) and the verb starts with a slash ( / ). But Apache Camel will take care of this and remove the duplicated slash.

 

 

camel-example-spark-rest-tomcat

...

OptionDefaultDescription
component The Camel Rest component to use for the REST transport, such as restlet, spark-rest. If no component has been explicit configured, then Camel will lookup if there is a Camel component that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry. If either one is found, then that is being used.
schemehttpThe scheme to use for exposing the REST service. Usually http or https is supported
hostname0.0.0.0The hostname to use for exposing the REST service.
port The port number to use for exposing the REST service.
property Allows to configure as many additional properties. This is used to configure component specific options such as for Restlet / Spark-Rest etc.

...


For example to configure to use the spark-rest component on port 9091, then we can do as follows

Code Block
restConfiguration().component("spark-rest").port(9091).property("foo", "123");

...

And with XML DSL

Code Block
    <restConfiguration component="spark-rest" port="9091">
      <restProperty key="foo" value="123"/>
    </restConfiguration>

Integration a Camel component with Rest DSL

Any Apache Camel component can integrate with the Rest DSL if they can be used as a REST service (eg as a REST consumer in Camel lingo). To integrate with the Rest DSL, then the component should implement the org.apache.camel.spi.RestConsumerFactory. The Rest DSL will then invoke the createConsumer method when it setup the Camel routes from the defined DSL. The component should then implement logic to create a Camel consumer that exposes the REST services based on the given parameters, such as path, verb, and other options. For example see the source code for camel-restlet, camel-spark-rest. 

 

See Also