Class RestConfigurationProperties

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.camel.spi.BootstrapCloseable

    @Configurer(bootstrap=true)
    public class RestConfigurationProperties
    extends org.apache.camel.spi.RestConfiguration
    implements org.apache.camel.spi.BootstrapCloseable
    Global configuration for Rest DSL.
    • Method Detail

      • withComponent

        public RestConfigurationProperties withComponent​(String component)
        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

        public RestConfigurationProperties withApiComponent​(String apiComponent)
        The name of the Camel component to use as the REST API (such as swagger)
      • withProducerComponent

        public RestConfigurationProperties withProducerComponent​(String producerComponent)
        Sets the name of the Camel component to use as the REST producer
      • withScheme

        public RestConfigurationProperties withScheme​(String scheme)
        The scheme to use for exposing the REST service. Usually http or https is supported.

        The default value is http

      • withApiHost

        public RestConfigurationProperties withApiHost​(String apiHost)
        To use an specific hostname for the API documentation (eg swagger)

        This can be used to override the generated host with this configured hostname

      • withUseXForwardHeaders

        public RestConfigurationProperties withUseXForwardHeaders​(boolean useXForwardHeaders)
        Whether to use X-Forward headers for Host and related setting.

        The default value is true.

      • withPort

        public RestConfigurationProperties withPort​(int 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.
      • withProducerApiDoc

        public RestConfigurationProperties 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. This requires adding camel-swagger-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

        public RestConfigurationProperties withContextPath​(String contextPath)
        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

        public RestConfigurationProperties withApiContextPath​(String apiContextPath)
        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

        public RestConfigurationProperties withApiContextRouteId​(String apiContextRouteId)
        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.

      • withApiContextIdPattern

        public RestConfigurationProperties withApiContextIdPattern​(String apiContextIdPattern)
        Sets an CamelContext id pattern to only allow Rest APIs from rest services within CamelContext's which name matches the pattern.

        The pattern #name# refers to the CamelContext name, to match on the current CamelContext only. For any other value, the pattern uses the rules from PatternHelper.matchPattern(String, String)

      • withApiContextListing

        public RestConfigurationProperties withApiContextListing​(boolean apiContextListing)
        Sets whether listing of all available CamelContext's with REST services in the JVM is enabled. If enabled it allows to discover these contexts, if false then only the current CamelContext is in use.
      • withApiVendorExtension

        public RestConfigurationProperties withApiVendorExtension​(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.
      • withHostNameResolver

        public RestConfigurationProperties 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. The possible values are: allLocalIp, localIp, localHostName
      • withBindingMode

        public RestConfigurationProperties withBindingMode​(String bindingMode)
        Sets the binding mode to use.

        The possible values are: auto, off, json, xml, json_xml The default value is off

      • withSkipBindingOnErrorCode

        public RestConfigurationProperties withSkipBindingOnErrorCode​(boolean skipBindingOnErrorCode)
        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

        public RestConfigurationProperties withClientRequestValidation​(boolean clientRequestValidation)
        Whether to enable validation of the client request to check whether the Content-Type and Accept headers from the client is supported by the Rest-DSL configuration of its consumes/produces settings.

        This can be turned on, to enable this check. In case of validation error, then HTTP Status codes 415 or 406 is returned.

        The default value is false.

      • withEnableCORS

        public RestConfigurationProperties withEnableCORS​(boolean enableCORS)
        Whether to enable CORS headers in the HTTP response.

        The default value is false.

      • withJsonDataFormat

        public RestConfigurationProperties withJsonDataFormat​(String 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.
      • withXmlDataFormat

        public RestConfigurationProperties withXmlDataFormat​(String 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.