Camel Components

Platform Http Main

Since Camel 4.0

The camel-platform-http-main is an embedded HTTP server for camel-main standalone applications.

The embedded HTTP server is using VertX from the camel-platform-http-vertx dependency.

Enabling

The HTTP server for camel-main is disabled by default, and you need to explicitly enable this by setting camel.server.enabled=true in application.properties.

Auto-detection from classpath

To use this implementation all you need to do is to add the camel-platform-http-main dependency to the classpath. Then, the platform http component should auto-detect this.

Uploading and downloading files

The embedded HTTP server comes with a set of features out of the box (management, development and user services), that can be enabled.

These features are as follows:

  • / - Serving static content such as html, javascript, css, and images to make it easy to embed very small web applications.

  • /observe/info - Report basic information about Camel

  • /observe/health - Health checks

  • /observe/jolokia - To use Jolokia to expose JMX over HTTP REST

  • /observe/metrics - To provide OTEL metrics in prometheus format

  • /q/dev - Developer console that provides a lot of statistics and information (supports both GET and POST; POST accepts a JSON body)

  • /q/upload - Uploading source files, to allow hot reloading.

  • /q/download - Downloading source files, to allow inspecting

  • /q/send - Sending messages to the Camel application via HTTP

You configure these features in the application.properties file using the camel.server.xxx and camel.management.xxx options.

Downloading files

File download is enabled with camel.management.downloadEnabled=true.

Calling /q/download without a file name returns a list of the files that can be downloaded. By default, the list only contains the source files of the routes (such as *.camel.yaml files). To also list the resources of the application, add the classpath=true query parameter. These are the resources from the classpath directories (such as target/classes) and from the application JAR when the application is packaged, and when using camel run the files from the project directory (such as application.properties and openapi.json). The content of the dependency JARs is not included.

# list route source files
curl http://localhost:8080/q/download

# list route source files and the resources of the application
curl http://localhost:8080/q/download?classpath=true

The list can be filtered with an Ant-style pattern as the file name, for example to list only the properties files:

curl http://localhost:8080/q/download/*.properties?classpath=true

When the Accept header includes html (such as from a web browser), the list is returned as HTML links.

To download a file, call /q/download/ followed by the file name. The file is resolved from the classpath first, then from the route source files, and when using camel run from the project directory. A file on the classpath can be downloaded even if it is not listed (when not using classpath=true).

curl http://localhost:8080/q/download/application.properties

JWT authentication

The embedded HTTP server can validate JWT bearer tokens on incoming requests. Token signatures are verified against a keystore, and the exp and nbf claims are checked.

jwtIssuer and/or jwtAudience must be set so that the iss and aud claims are validated as well. Without them a token is accepted on the strength of its signature and expiry alone, which means any unexpired token signed by a key the keystore trusts is accepted no matter which issuer minted it or which audience it was intended for. The server therefore fails to start when a JWT keystore is configured but neither value is set.

camel.server.enabled=true
camel.server.authenticationEnabled=true
camel.server.authenticationPath=/*

camel.server.jwtKeystoreType=jks
camel.server.jwtKeystorePath=keystore.jks
camel.server.jwtKeystorePassword=changeme

camel.server.jwtIssuer=https://issuer.example.com
camel.server.jwtAudience=api,internal-api

jwtAudience accepts a comma-separated list of values. A token is accepted if its aud claim contains any of the configured values.

If a deployment genuinely wants signature and expiry validation only, set camel.server.jwtAllowMissingIssuerAndAudience=true to allow the server to start without an issuer or an audience.

The same options are available on the management server as camel.management.jwtIssuer, camel.management.jwtAudience and camel.management.jwtAllowMissingIssuerAndAudience.