You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Rest Component

Available as of Camel 2.14

The rest component allows to define REST endpoints using the Rest DSL and plugin to other Camel components as the REST transport.

 

URI format

  rest://verb:path?[options]

URI Options

Name

Default Value

Description

verb

 

get, post, put, patch, delete, head, trace, connect, or options.

path

 

the content path which support REST syntax. See further below for examples.

consumes

 

accept type such as: 'text/xml', or 'application/json'. By default we accept all kinds of types.

Path syntax

The path option is defined using a REST syntax where you define the REST context path using support for parameters. 

The following is a Camel route using a fixed path

  from("rest:get:hello")
    .transform().constant("Bye World");

And the following route uses a parameter which is mapped to a Camel header with the key "me".

  from("rest:get:hello/{me}")
    .transform().simple("Bye ${header.me}");

More examples

There is a camel-example-spark-rest-tomcat example in the Apache Camel distribution, that demonstrates how to use the Rest DSL with the Spark-rest as transport that can be deployed on Apache Tomcat, or similar web containers.

  • No labels