Smile provides a configurable Camel HTTP Endpoint for receiving calls to URLs and passing those requests to Camel routes.
The Camel HTTP Endpoint module must be configured with a set of mappings to control how incoming HTTP requests are connected to Camel routes. The configuration takes the form of a JSON document.
{
"mappings": [
{
"name": "myReadMapping",
"path": "/myRelativePath",
"methods": ["GET"],
"targetRoute": "direct:camelReadRoute",
"headers": ["accept", "accept-encoding", "pragma", "cache-control"]
},
{
"name": "myWriteMapping",
"path": "/myRelativePath",
"methods": ["PUT", "POST"],
"targetRoute": "direct:camelWriteRoute",
"headers": ["content-type", "content-length", "CamelHttpMethod"]
}
]
}
Assuming that the endpoint module is configured to listen on port 8004, an HTTP request to GET https://myhost.com:8004/myRelativePath will be passed to the Camel route consuming from the URI default:camelReadRoute. If multiple mappings in the configuration match the incoming request, the one that occurs first in the document will be given priority.
If a mapping configuration is not provided, all requests on https://myhost.com:8004/ will be passed to the Camel route consuming from the URI direct:camel-http-endpoint.
Each mapping can specify the following parameters.
| Parameter | Use |
|---|---|
| name | An optional name for the mapping. This name will be used in the permissions to restrict access to this mapping to certain users. |
| path | The relative URL path that matches this mapping. This parameter uses Ant path format. |
| methods | The HTTP methods accepted by this mapping. If this parameter is not specified, all HTTP methods will be accepted on this mapping. |
| targetRoute | The URI that the target Camel route consumes from. |
| headers | The HTTP headers that will be copied into the Camel Exchange. If this parameter is not specified, all available headers will be included in the exchange. |
The endpoint will copy the body of the HTTP request to the body of the Camel exchange message.
By default, the endpoint will copy all headers from the HTTP request as headers of the Camel exchange message, except for the Authorization header. The following special headers will also be populated.
| Header | Contents | Example value |
|---|---|---|
| CamelHttpProtocolVersion | The version of the http protocol used. | HTTP/1.1 |
| CamelHttpMethod | The http method of the request. | GET |
| CamelHttpCharacterEncoding | The character encoding of the request. | UTF-8 |
| CamelHttpUri | The relative URI of the request. | /myPath |
| CamelHttpQuery | The query parameters of the request. | param=value |
| CamelHttpPath | The absolute path of the request. This includes both the URI and the query. | https://myhost.com:8004/myPath?param=value |
The headers parameter of the mapping configuration can be used to restrict which headers will be copied.
One of the following properties will be populated on the Camel exchange, providing the details of how the request was authenticated.
| Property | Data Type | Description |
|---|---|---|
ca.cdr.camel.property.usersession.object | ca.cdr.api.model.json.UserSessionDetailsJson | The details of a user session. |
ca.cdr.camel.property.clientsession.object | ca.cdr.api.model.json.OAuth2ClientDetailsJson | The details of a client session. |
Once the Camel route has completed execution, the body and headers will be copied from the Camel exchange to the HTTP response. The value of the header CamelHttpResponseCode will be used as the HTTP response code. If this header is not present, the default response code will be 200 OK.
In order to access the Camel HTTP Endpoint, a user must be granted one of the following permissions.
INVOKE_ANY_CAMEL_HTTP_ENDPOINT - This permission grants access to all mapped URLs on any instance of the endpoint module.INVOKE_ALL_CAMEL_HTTP_ENDPOINTS_ON_MODULE/moduleId - This permission grants access to all mapped URLs on a single instance of the endpoint module.INVOKE_CAMEL_HTTP_ENDPOINT/moduleId/mappingName - This permission grants access to a single mapping on a single instance of the endpoint module.You are about to leave the Smile Digital Health documentation and navigate to the Open Source HAPI-FHIR Documentation.