Versions Compared

Key

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

...

Code Block
  rest://method:path[:uriTemplate]?[options]

URI Options

Wiki Markup
|| Name || Default Value || Description ||
| method |  | HTTP method which should be one of: get, post, put, patch, delete, head, trace, connect, or options. |
| path | | the base path which support REST syntax. See further below for examples. |
| uriTemplate | | uri template which support REST syntax. See further below for examples. |
| consumes |  | media type such as: 'text/xml', or 'application/json' this REST service accepts. By default we accept all kinds of types. |
| produces |  | media type such as: 'text/xml', or 'application/json' this REST service returns. |

Path and uriTemplate syntax

Name

Default Value

Description

method

 

HTTP method which should be one of:

  • get
  • post
  • put
  • patch
  • delete
  • head
  • trace
  • connect
  • options

path

 

The base path which support REST syntax.

See further below for examples.

uriTemplate

 

URI template which support REST syntax.

See further below for examples.

consumes

 

Media type such as: text/xml or application/json this REST service accepts.

By default we accept all kinds of types.

produces

 

Media type such as: text/xml or application/json this REST service returns.

Path and uriTemplate syntax

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

Tip

If no no uriTemplate is configured then path option works the same way. It does not matter if you configure only path or if you configure both options. Though configuring both a path and and uriTemplate is a more common practice with REST.

...

The following is a Camel route using a a path only

Code Block
languagejava
  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".:

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

...

The following examples have configured a base path as "as hello" and then have two REST services configured using uriTemplates uriTemplate's.

 

Code Block
languagejava
  from("rest:get:hello:/{me}")
    .transform().simple("Hi ${header.me}");
 
  from("rest:get:hello:/french/{me}")
    .transform().simple("Bonjour ${header.me}");

...