이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 117. Rest


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://method:path[:uriTemplate]?[options]
Copy to Clipboard Toggle word wrap

URI Options

Expand
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

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 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 uriTemplate is a more common practice with REST.
The following is a Camel route using a a path only
  from("rest:get:hello")
    .transform().constant("Bye World");
Copy to Clipboard Toggle word wrap
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}");
Copy to Clipboard Toggle word wrap
The following examples have configured a base path as "hello" and then have two REST services configured using uriTemplates.
  from("rest:get:hello:/{me}")
    .transform().simple("Hi ${header.me}");
 
  from("rest:get:hello:/french/{me}")
    .transform().simple("Bonjour ${header.me}");
Copy to Clipboard Toggle word wrap

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-servlet-rest-tomcat example in the Apache Camel distribution, that demonstrates how to use the Rest DSL with SERVLET as transport that can be deployed on Apache Tomcat, or similar web containers.
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat