Integration Gateway
The Integration gateway facility allows you to define custom endpoints that can support custom authentication methods, request validation and rate limiting.
Integration gateway serves as an alternative to sink endpoints. |
These endpoints can be used to define a custom endpoint for incoming webhooks, to process data provided by some external integration, or to proxy requests to another service.
Most of the basic operations can be achieved with the built-in functionality; more advanced operations can be implemented with simple JavaScript code snippets or workflows.
Defining a New Endpoint
To define a new endpoint, navigate to your Corteza instance (for example http://latest.cortezaproject.org/) and click on the "admin area" application.
In the admin area, navigate to the
sub-page. From the admin area, you can create and update your endpoints, as well as manage their access control.When you click on the new button, a new screen will appear where you need to provide the base parameters of your endpoint.
-
Endpoint defines the path for the endpoint,
-
method defines the HTTP method for the endpoint.
The endpoint will be accessible under $BASE_URL/api/gateway$YOUR_ENDPOINT
.
To exemplify; the /test-endpoint
endpoint for the https://latest.cortezaproject.org
instance is available as https://latest.cortezaproject.org/api/gateway/test-endpoint
.
You can specify different HTTP methods on the same route, but they need to be specified as different endpoints, ie. |
When you submit the forum, an additional "filter list" section opens below the base parameters. These filters allow you to validate and process requests, as well as defining the response.
Subsequent sections explore specific filters in more depth; what they do, and how they should be used.
Request Validation
Request validation is done by using prefilters. prefilters allow you to validate the request and determine if the given endpoint should process it.
It is currently not possible to use the built-in authentication facility to authenticate requests. This feature will be added in the future. |
The query parameters prefilter allows you to define a condition which asserts if the request can be processed by this endpoint based on the query parameters. The query parameters are passed into the expression evaluation engine as they were provided.
To exemplify; the query parameters Refer to the expression reference for details regarding to writing these expressions. The following example checks whether the given HTTP request defines the Endpoint definition:
An example of an HTTP request that conforms to the filter:
An example of an HTTP request that does not conform to the filter:
|
|||
The header prefilter allows you to define a condition which asserts whether the request can be processed by this endpoint based on the request’s headers. All system defined headers are passed into the expression evaluation engine as provided.
User-define headers will automatically be converted into the The following header Refer to the expression reference for details regarding writing these expressions. The following example checks if the given HTTP request defines the Endpoint definition:
An example of an HTTP request that conforms to the filter:
An example of an HTTP request that does not conform to the filter:
|
|||
The profiler prefilter enables a specific endpoint to gather useful statistics on an incoming route, such as headers, request body, content length, and request URI. The prefilter can be added after any See more on adding a profiler prefilter on the profiler page. |
Request Processing
Request processing is done using processers. A processer defines the core business logic that the endpoint performs. Corteza allows you to process arbitrary payloads, such as a structured JSON or a binary attachment.
The workflow processer allows you to bind a workflow to the endpoint. Refer to the workflow processing page for details regarding the interaction. |
|
The payload processer allows you to handle the request’s payload with the help of JavaScript. Refer to the Process Requests with JavaScript section for more details. |
Response Preparation
Response preparation is done using postfilters. Postfilters allow you to finalize the request lifecycle depending on the result of the processing.
The redirect postfilter enriches the response payload with the required redirect HTTP headers. |
|
The JSON response postfilter enriches the response headers with the |
Debugging
System Logs
Enable debug logging in your .env
file.
Refer to the DevOps guide for details.
Inspecting Docker Logs
By default, Corteza logs are accessible via Docker logs. To access these logs, you need to firstly navigate to the directory where your Corteza instance resides in.
cd /opt/deploy/{CORTEZA_INSTANCE}/
You can use the docker-compose logs server
command to access the logs output by the server
.
Refer to the |
docker-compose logs -f --tail=20 server
server_1 | 12:53:14.862 DEBUG rbac rbac/service.go:102 allow delete for corteza::compose:record/245030892240891907/245030893465497603/246932114543603715 {"bypass": [], "context": [], "common": [245030892072923139], "authenticated": [245030891334791171], "anonymous": [], "identity": 250804535289769987, "indexed": 63, "rules": 420}
You can also use grep
or log filtering to show only specific logs.
Refer to the DevOps guide for details regarding logging.
grep
to show only debug logs:user@server:/opt/deploy/{CORTEZA_INSTANCE}/$ docker-compose logs -f --tail=20 server | grep DEBUG
server_1 | 13:52:29.636 DEBUG rbac rbac/service.go:102 allow triggers.manage for corteza::automation:workflow/248229091554160643
Last updated 2021-09-27 18:01:45 +0200
Some content has been disabled in this document