Versions Compared

Key

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

...

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
hostname The hostname to use for exposing the REST service.
port The port number to use for exposing the REST service. Notice if you use servlet component then the port number configured here does not apply, as the port number in use is the actual port number the servlet component is using. eg if using Apache Tomcat its the tomcat http port, if using Apache Karaf its the HTTP service in Karaf that uses port 8181 by default etc. Though in those situations setting the port number here, allows tooling and JMX to know the port number, so its recommended to set the port number to the number that the servlet engine uses.
contextPath Sets a leading context-path the REST services will be using. This can be used when using components such as SERVLET where the deployed web application is deployed using a context-path.
restHostNameResolverlocalHostNameIf no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using. The resolver supports localHostName or localIp.
bindingModeoffWhether binding is in use. See further above for more details.
skipBindingOnCustomErrortrueCamel 2.14.1: Whether to skip binding on output if there is a custom HTTP error code header. This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do. See further below for an example.
enableCORSfalseCamel 2.14.1: Whether to enable CORS headers in the HTTP response.
jsonDataFormat Name of specific json data format to use. By default json-jackson will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance. Notice: Currently Jackson is what we recommend and are using for testing.
xmlDataFormat Name of specific XML data format to use. By default jaxb will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance. Notice: Currently only jaxb is supported.
componentProperty Allows to configure as many additional properties. This is used to configure component specific options such as for Restlet / Spark-Rest etc.
endpointProperty Allows to configure as many additional properties. This is used to configure endpoint specific options for  Restlet / Spark-Rest etc.
consumerProperty Allows to configure as many additional properties. This is used to configure consumer specific options for  Restlet / Spark-Rest etc.
dataFormatProperty Allows to configure as many additional properties. This is used to configure the data format specific options. For example set property prettyPrint to true to have json outputted in pretty mode.
corsHeaderProperty Allows to configure custom CORS headers.

 

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

...

  • component - Is used to set any options on the Component class. You can also configure these directly on the component.
  • endpoint - Is used set any option on the endpoint level. Many of the Camel components has many options you can set on endpoint level.
  • consumer - Is used to set any option on the consumer level. Some components has consumer options, which you can also configure from endpoint level by prefixing the option with "consumer." 
  • data format - Is used to set any option on the data formats. For example to enable pretty print in the json data format.
  • cors headers - If cors is enabled, then custom CORS headers can be set. See below for the default values which are in used. If a custom header is set then that value takes precedence over the default value.

You can set multiple options of the same level, so you can can for example configure You can set multiple options of the same level, so you can can for example configure 2 component options, and 3 endpoint options etc.

Default CORS headers

Available as of Camel 2.14.1

If CORS is enabled then the follow headers is in use by default. You can configure custom CORS headers which takes precedence over the default value.

KeyValue
Access-Control-Allow-Origin*
Access-Control-Allow-MethodsGET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
Access-Control-Allow-HeadersOrigin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers
Access-Control-Max-Age3600

 

Defining a custom error message as-is

...