Package org.apache.camel.spi
Class RestConfiguration
java.lang.Object
org.apache.camel.spi.RestConfiguration
Configuration use by
RestConsumerFactory
and
RestApiConsumerFactory
for Camel components to support the Camel
rest
DSL.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the name of the Camel component to use as the REST API (such as swagger or openapi).Gets the binding mode used by the REST consumerGets the name of the Camel component to use as the REST consumerGets additional options on component levelGets additional options on consumer levelGets the configured context-pathGets the CORS headers to use if CORS has been enabled.Gets additional options on data format levelGets additional options on endpoint levelgetHost()
Gets the hostname to use by the REST consumerGets the resolver to use for resolving hostnameGets the name of the json data format.int
getPort()
Gets the port to use by the REST consumerGets 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.Gets the name of the Camel component to use as the REST producerGets the scheme to use by the REST consumerGets the name of the xml data format.boolean
boolean
boolean
To specify whether to enable CORS which means Camel will automatic include CORS in the HTTP headers in the response.boolean
boolean
Whether to skip binding output if there is a custom HTTP error code, and instead use the response body as-is.boolean
Whether to use X-Forward headers to set host etc.void
setApiComponent
(String apiComponent) Sets the name of the Camel component to use as the REST API (such as swagger or openapi)void
setApiContextPath
(String contextPath) Sets a leading API context-path the REST API services will be using.void
setApiContextRouteId
(String apiContextRouteId) Sets the route id to use for the route that services the REST API.void
setApiHost
(String apiHost) To use a specific hostname for the API documentation (such as swagger or openapi)void
setApiProperties
(Map<String, Object> apiProperties) Sets additional options on api levelvoid
setApiVendorExtension
(boolean apiVendorExtension) Whether vendor extension is enabled in the Rest APIs.void
setBindingMode
(String bindingMode) Sets the binding mode to be used by the REST consumervoid
setBindingMode
(RestConfiguration.RestBindingMode bindingMode) Sets the binding mode to be used by the REST consumervoid
setClientRequestValidation
(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.void
setComponent
(String componentName) Sets the name of the Camel component to use as the REST consumervoid
setComponentProperties
(Map<String, Object> componentProperties) Sets additional options on component levelvoid
setConsumerProperties
(Map<String, Object> consumerProperties) Sets additional options on consumer levelvoid
setContextPath
(String contextPath) Sets a leading context-path the REST services will be using.void
setCorsHeaders
(Map<String, String> corsHeaders) Sets the CORS headers to use if CORS has been enabled.void
setDataFormatProperties
(Map<String, Object> dataFormatProperties) Sets additional options on data format levelvoid
setEnableCORS
(boolean enableCORS) To specify whether to enable CORS which means Camel will automatic include CORS in the HTTP headers in the response.void
setEndpointProperties
(Map<String, Object> endpointProperties) Sets additional options on endpoint levelvoid
Sets the hostname to use by the REST consumervoid
setHostNameResolver
(String hostNameResolver) Sets the resolver to use for resolving hostnamevoid
setHostNameResolver
(RestConfiguration.RestHostNameResolver hostNameResolver) Sets the resolver to use for resolving hostnamevoid
setInlineRoutes
(boolean inlineRoutes) Inline routes in rest-dsl which are linked using direct endpoints.void
setJsonDataFormat
(String name) Sets a custom json data format to be usedvoid
setPort
(int port) Sets the port to use by the REST consumervoid
setProducerApiDoc
(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.void
setProducerComponent
(String componentName) Sets the name of the Camel component to use as the REST producervoid
Sets the scheme to use by the REST consumervoid
setSkipBindingOnErrorCode
(boolean skipBindingOnErrorCode) Whether to skip binding output if there is a custom HTTP error code, and instead use the response body as-is.void
setUseXForwardHeaders
(boolean useXForwardHeaders) Whether to use X-Forward headers to set host etc.void
setXmlDataFormat
(String name) Sets a custom xml data format to be used.
-
Field Details
-
CORS_ACCESS_CONTROL_ALLOW_ORIGIN
- See Also:
-
CORS_ACCESS_CONTROL_ALLOW_METHODS
- See Also:
-
CORS_ACCESS_CONTROL_MAX_AGE
- See Also:
-
CORS_ACCESS_CONTROL_ALLOW_HEADERS
- See Also:
-
DEFAULT_REST_CONFIGURATION_ID
- See Also:
-
-
Constructor Details
-
RestConfiguration
public RestConfiguration()
-
-
Method Details
-
getComponent
Gets the name of the Camel component to use as the REST consumer- Returns:
- the component name, or null to let Camel search the
Registry
to find suitable implementation
-
setComponent
Sets the name of the Camel component to use as the REST consumer- Parameters:
componentName
- the name of the component (such as netty-http, jetty, servlet, undertow, etc.)
-
getApiComponent
Gets the name of the Camel component to use as the REST API (such as swagger or openapi).- Returns:
- the component name
-
setApiComponent
Sets the name of the Camel component to use as the REST API (such as swagger or openapi)- Parameters:
apiComponent
- the name of the component (such as swagger or openapi)
-
getProducerComponent
Gets the name of the Camel component to use as the REST producer- Returns:
- the component name, or null to let Camel search the
Registry
to find suitable implementation
-
setProducerComponent
Sets the name of the Camel component to use as the REST producer- Parameters:
componentName
- the name of the component (such as http, netty-http, undertow, etc.)
-
getProducerApiDoc
Gets 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. -
setProducerApiDoc
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. -
getHost
Gets the hostname to use by the REST consumer- Returns:
- the hostname, or null to use default hostname
-
setHost
Sets the hostname to use by the REST consumer- Parameters:
host
- the hostname
-
isUseXForwardHeaders
public boolean isUseXForwardHeaders()Whether to use X-Forward headers to set host etc. for Swagger. This option is default true. -
setUseXForwardHeaders
public void setUseXForwardHeaders(boolean useXForwardHeaders) Whether to use X-Forward headers to set host etc. for Swagger. This option is default true. -
getApiHost
-
setApiHost
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 -
getScheme
Gets the scheme to use by the REST consumer- Returns:
- the scheme, or null to use default scheme
-
setScheme
Sets the scheme to use by the REST consumer- Parameters:
scheme
- the scheme
-
getPort
public int getPort()Gets the port to use by the REST consumer- Returns:
- the port, or 0 or -1 to use default port
-
setPort
public void setPort(int port) Sets the port to use by the REST consumer- Parameters:
port
- the port number
-
getContextPath
Gets the configured context-path- Returns:
- the context path, or null if none configured.
-
setContextPath
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.- Parameters:
contextPath
- the context path
-
getApiContextPath
-
setApiContextPath
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.- Parameters:
contextPath
- the API context path
-
getApiContextRouteId
-
setApiContextRouteId
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.- Parameters:
apiContextRouteId
- the route id
-
isApiVendorExtension
public boolean isApiVendorExtension() -
setApiVendorExtension
public void setApiVendorExtension(boolean apiVendorExtension) 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. -
getHostNameResolver
Gets the resolver to use for resolving hostname- Returns:
- the resolver
-
setHostNameResolver
Sets the resolver to use for resolving hostname- Parameters:
hostNameResolver
- the resolver
-
setHostNameResolver
Sets the resolver to use for resolving hostname- Parameters:
hostNameResolver
- the resolver
-
getBindingMode
Gets the binding mode used by the REST consumer- Returns:
- the binding mode
-
setBindingMode
Sets the binding mode to be used by the REST consumer- Parameters:
bindingMode
- the binding mode
-
setBindingMode
Sets the binding mode to be used by the REST consumer- Parameters:
bindingMode
- the binding mode
-
isSkipBindingOnErrorCode
public boolean isSkipBindingOnErrorCode()Whether to skip binding output if there is a custom HTTP error code, and instead use the response body as-is. This option is default true.- Returns:
- whether to skip binding on error code
-
setSkipBindingOnErrorCode
public void setSkipBindingOnErrorCode(boolean skipBindingOnErrorCode) Whether to skip binding output if there is a custom HTTP error code, and instead use the response body as-is. This option is default true.- Parameters:
skipBindingOnErrorCode
- whether to skip binding on error code
-
isClientRequestValidation
public boolean isClientRequestValidation() -
setClientRequestValidation
public void setClientRequestValidation(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. -
isEnableCORS
public boolean isEnableCORS()To specify whether to enable CORS which means Camel will automatic include CORS in the HTTP headers in the response. This option is default false- Returns:
- whether CORS is enabled or not
-
setEnableCORS
public void setEnableCORS(boolean enableCORS) To specify whether to enable CORS which means Camel will automatic include CORS in the HTTP headers in the response. This option is default false- Parameters:
enableCORS
- true to enable CORS
-
isInlineRoutes
public boolean isInlineRoutes() -
setInlineRoutes
public void setInlineRoutes(boolean inlineRoutes) 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. -
getJsonDataFormat
Gets the name of the json data format. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.- Returns:
- the name, or null to use default
-
setJsonDataFormat
Sets a custom json data format to 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.- Parameters:
name
- name of the data format
-
getXmlDataFormat
Gets the name of the xml data format. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.- Returns:
- the name, or null to use default
-
setXmlDataFormat
Sets a custom xml data format to 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.- Parameters:
name
- name of the data format
-
getComponentProperties
Gets additional options on component level- Returns:
- additional options
-
setComponentProperties
Sets additional options on component level- Parameters:
componentProperties
- the options
-
getEndpointProperties
Gets additional options on endpoint level- Returns:
- additional options
-
setEndpointProperties
Sets additional options on endpoint level- Parameters:
endpointProperties
- the options
-
getConsumerProperties
Gets additional options on consumer level- Returns:
- additional options
-
setConsumerProperties
Sets additional options on consumer level- Parameters:
consumerProperties
- the options
-
getDataFormatProperties
Gets additional options on data format level- Returns:
- additional options
-
setDataFormatProperties
Sets additional options on data format level- Parameters:
dataFormatProperties
- the options
-
getApiProperties
-
setApiProperties
Sets additional options on api level- Parameters:
apiProperties
- the options
-
getCorsHeaders
Gets the CORS headers to use if CORS has been enabled.- Returns:
- the CORS headers
-
setCorsHeaders
Sets the CORS headers to use if CORS has been enabled.- Parameters:
corsHeaders
- the CORS headers
-