Package org.apache.camel.main
Class RestConfigurationProperties
java.lang.Object
org.apache.camel.spi.RestConfiguration
org.apache.camel.main.RestConfigurationProperties
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.camel.spi.BootstrapCloseable
@Configurer(bootstrap=true,
extended=true)
public class RestConfigurationProperties
extends org.apache.camel.spi.RestConfiguration
implements org.apache.camel.spi.BootstrapCloseable
Global configuration for Rest DSL.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.camel.spi.RestConfiguration
org.apache.camel.spi.RestConfiguration.RestBindingMode, org.apache.camel.spi.RestConfiguration.RestHostNameResolver -
Field Summary
Fields inherited from class org.apache.camel.spi.RestConfiguration
CORS_ACCESS_CONTROL_ALLOW_HEADERS, CORS_ACCESS_CONTROL_ALLOW_METHODS, CORS_ACCESS_CONTROL_ALLOW_ORIGIN, CORS_ACCESS_CONTROL_MAX_AGE, DEFAULT_REST_CONFIGURATION_ID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()end()withApiComponent(String apiComponent) The name of the Camel component to use as the REST API (such as swagger)withApiContextPath(String apiContextPath) Sets a leading API context-path the REST API services will be using.withApiContextRouteId(String apiContextRouteId) Sets the route id to use for the route that services the REST API.withApiHost(String apiHost) To use a specific hostname for the API documentation (such as swagger or openapi)withApiProperty(String key, Object value) Adds a api propertywithApiVendorExtension(boolean apiVendorExtension) Whether vendor extension is enabled in the Rest APIs.withBindingMode(String bindingMode) Sets the binding mode to use.withBindingPackageScan(String bindingPackageScan) Package name to use as base (offset) for classpath scanning of POJO classes are located when using binding mode is enabled for JSon or XML.withClientRequestValidation(boolean clientRequestValidation) Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error. 2) Accept header matches what the Rest DSL produces; returns HTTP Status 406 if validation error. 3) Missing required data (query parameters, HTTP headers, body); returns HTTP Status 400 if validation error. 4) Parsing error of the message body (JSon, XML or Auto binding mode must be enabled); returns HTTP Status 400 if validation error.withComponent(String component) The Camel Rest component to use for the REST transport (consumer), such as netty-http, jetty, servlet, undertow.withComponentProperty(String key, Object value) Adds a component propertywithConsumerProperty(String key, Object value) Adds a consumer propertywithContextPath(String contextPath) Sets a leading context-path the REST services will be using.withCorsHeader(String key, String value) Adds a CORS header propertywithDataFormatProperty(String key, Object value) Adds a data format propertywithEnableCORS(boolean enableCORS) Whether to enable CORS headers in the HTTP response.withEndpointProperty(String key, Object value) Adds a endpoint propertyThe hostname to use for exposing the REST service.withHostNameResolver(String hostNameResolver) If no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using.withInlineRoutes(boolean inlineRoutes) Inline routes in rest-dsl which are linked using direct endpoints.withJsonDataFormat(String jsonDataFormat) Name of specific json data format to use.withPort(int port) The port number to use for exposing the REST service.withProducerApiDoc(String producerApiDoc) Sets the location of the api document (swagger api) the REST producer will use to validate the REST uri and query parameters are valid accordingly to the api document.withProducerComponent(String producerComponent) Sets the name of the Camel component to use as the REST producerwithScheme(String scheme) The scheme to use for exposing the REST service.withSkipBindingOnErrorCode(boolean skipBindingOnErrorCode) Whether to skip binding on output if there is a custom HTTP error code header.withUseXForwardHeaders(boolean useXForwardHeaders) Whether to use X-Forward headers to set host etc. for OpenApi.withXmlDataFormat(String xmlDataFormat) Name of specific XML data format to use.Methods inherited from class org.apache.camel.spi.RestConfiguration
getApiComponent, getApiContextPath, getApiContextRouteId, getApiHost, getApiProperties, getBindingMode, getBindingPackageScan, getComponent, getComponentProperties, getConsumerProperties, getContextPath, getCorsHeaders, getDataFormatProperties, getEndpointProperties, getHost, getHostNameResolver, getJsonDataFormat, getPort, getProducerApiDoc, getProducerComponent, getScheme, getXmlDataFormat, isApiVendorExtension, isClientRequestValidation, isEnableCORS, isEnableNoContentResponse, isInlineRoutes, isSkipBindingOnErrorCode, isUseXForwardHeaders, setApiComponent, setApiContextPath, setApiContextRouteId, setApiHost, setApiProperties, setApiVendorExtension, setBindingMode, setBindingMode, setBindingPackageScan, setClientRequestValidation, setComponent, setComponentProperties, setConsumerProperties, setContextPath, setCorsHeaders, setDataFormatProperties, setEnableCORS, setEnableNoContentResponse, setEndpointProperties, setHost, setHostNameResolver, setHostNameResolver, setInlineRoutes, setJsonDataFormat, setPort, setProducerApiDoc, setProducerComponent, setScheme, setSkipBindingOnErrorCode, setUseXForwardHeaders, setXmlDataFormat
-
Constructor Details
-
RestConfigurationProperties
-
-
Method Details
-
end
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
withComponent
The Camel Rest component to use for the REST transport (consumer), such as netty-http, jetty, servlet, undertow. 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. -
withApiComponent
The name of the Camel component to use as the REST API (such as swagger) -
withProducerComponent
Sets the name of the Camel component to use as the REST producer -
withScheme
The scheme to use for exposing the REST service. Usually http or https is supported. The default value is http -
withHost
The hostname to use for exposing the REST service. -
withApiHost
To use a specific hostname for the API documentation (such as swagger or openapi) This can be used to override the generated host with this configured hostname -
withUseXForwardHeaders
Whether to use X-Forward headers to set host etc. for OpenApi. This may be needed in special cases involving reverse-proxy and networking going from HTTP to HTTPS etc. Then the proxy can send X-Forward headers (X-Forwarded-Proto) that influences the host names in the OpenAPI schema that camel-openapi-java generates from Rest DSL routes. -
withPort
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. -
withProducerApiDoc
Sets the location of the api document (swagger api) the REST producer will use to validate the REST uri and query parameters are valid accordingly to the api document. This requires adding camel-openapi-java to the classpath, and any miss configuration will let Camel fail on startup and report the error(s). The location of the api document is loaded from classpath by default, but you can use file: or http: to refer to resources to load from file or http url. -
withContextPath
Sets a leading context-path the REST services will be using. This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path. Or for components such as camel-jetty or camel-netty-http that includes a HTTP server. -
withApiContextPath
Sets a leading API context-path the REST API services will be using. This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path. -
withApiContextRouteId
Sets the route id to use for the route that services the REST API. The route will by default use an auto assigned route id. -
withApiVendorExtension
Whether vendor extension is enabled in the Rest APIs. If enabled then Camel will include additional information as vendor extension (eg keys starting with x-) such as route ids, class names etc. Not all 3rd party API gateways and tools supports vendor-extensions when importing your API docs. -
withHostNameResolver
If no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using. The possible values are: allLocalIp, localIp, localHostName -
withBindingMode
Sets the binding mode to use. The possible values are: auto, off, json, xml, json_xml The default value is off -
withBindingPackageScan
Package name to use as base (offset) for classpath scanning of POJO classes are located when using binding mode is enabled for JSon or XML. Multiple package names can be separated by comma. -
withSkipBindingOnErrorCode
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. -
withClientRequestValidation
Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error. 2) Accept header matches what the Rest DSL produces; returns HTTP Status 406 if validation error. 3) Missing required data (query parameters, HTTP headers, body); returns HTTP Status 400 if validation error. 4) Parsing error of the message body (JSon, XML or Auto binding mode must be enabled); returns HTTP Status 400 if validation error. -
withEnableCORS
Whether to enable CORS headers in the HTTP response. The default value is false. -
withInlineRoutes
Inline routes in rest-dsl which are linked using direct endpoints. By default, each service in Rest DSL is an individual route, meaning that you would have at least two routes per service (rest-dsl, and the route linked from rest-dsl). Enabling this allows Camel to optimize and inline this as a single route, however this requires to use direct endpoints, which must be unique per service. This option is default false. -
withJsonDataFormat
Name of specific json data format to use. By default 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. -
withXmlDataFormat
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. -
withComponentProperty
Adds a component property -
withEndpointProperty
Adds a endpoint property -
withConsumerProperty
Adds a consumer property -
withDataFormatProperty
Adds a data format property -
withApiProperty
Adds a api property -
withCorsHeader
Adds a CORS header property
-