...
URI format
Code Block |
---|
rest://verbmethod:path[:uriTemplate]?[options] |
URI Options
Wiki Markup |
---|
|| 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
Name | Default Value | Description |
---|---|---|
|
| HTTP method which should be one of:
|
|
| The base path which support REST syntax. See further below for examples. |
|
| URI template which support REST syntax. See further below for examples. |
|
| Media type such as: By default we accept all kinds of types. |
|
| Media type such as: |
Path and uriTemplate
syntax
The path and uriTemplate
The path option is defined using a REST syntax where you define the REST context path using support for parameters.
Tip |
---|
If no |
The following is a Camel route using a a fixed path only
Code Block | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
from("rest:get:hello/{me}") .transform().simple("Bye ${header.me}"); |
The following examples have configured a base path as hello
and then have two REST services configured using uriTemplate
's.
Code Block | ||
---|---|---|
| ||
from("rest:get:hello:/{me}") .transform().simple("ByeHi ${header.me}"); from("rest:get:hello:/french/{me}") .transform().simple("Bonjour ${header.me}"); |
More examples
See Rest DSL which offers more examples and how you can use the Rest DSL to define those in a nicer RESTful way.
There is a camel-example-sparkservlet-rest-tomcat example in the Apache Camel distribution, that demonstrates how to use the Rest DSL with the Spark-rest as SERVLET as transport that can be deployed on Apache Tomcat, or similar web containers.
Include Page | ||||
---|---|---|---|---|
|