Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Calling the API can be done using HTTP method POST, PUT or GET.
Sending data to the API can be done by setting HTTP headers, request parameter or as a JSON structure in the request body.
Accessing data in a valve is done by using expansion.
Given the http request with body:
Using expansion in valve to access "firstkey" is done through ${request.firstkey}.
Lets say the request sent in something in the http header Authorization header.
Expanding data in the Authorization haders is done: ${request.header_firstkey}.
Note the "header_" prefix.
Here we highlight changes that may break previously working configurations unless adjusted to accommodate the updates below.
When a client invokes the API, the server initially cross-references the API configuration to determine if client authentication is required. If so, and if set up, authentication is processed through a PIPE. Only after successful authentication does the request get normalized and forwarded to the designated pipe for executing the core logic.
If the pipe executes without any errors, the response will carry an HTTP 200 status. Depending on the configuration and PIPE logic, the response body might include data.
On error API will return server 500 with potential error description. This can be changed using configuration.
Server for building custom APIs. An API consists of an endpoint bound to a URL via HTTP, a pipe for functionality, an optional pipe for auth, and pipes that can run on a schedule.
Client authentication is conducted through a PIPE. The PIPE involved in authentication has access to all data transmitted by the client. When designing an authentication PIPE, it's advisable to place the authentication data within the HTTP header.
A good design practice is to aim for lightweight authentication, especially since the client is authenticated with each request.
For enhanced security, don't rely solely on client authentication; if possible, incorporate additional layers of protection.
Instructions and information can be found .
API requires module API to be deployed. If endpoints are implemented in Pipes, the Pipes module must be deployed.
http_context
Base context (Default: "/api"
)
endpoints
List of api endpoint configurations
Each API endpoint represents an API with a unique context path and configurable authentication and request/response data. Endpoint logic can be implemented by a pipe but it is not required.
name
Endpoint name (Mandatory)
context_path
Endpoint relative path (Optional, defaults to name)
public
Flag turning on/off authentication for this endpoint (Default: false
)
auth.*
Endpoint authentication configuration
auth.pipe
Id of pipe performing endpoint authentication. Authentication is successful if pipe returns success, otherwise authentication fails. Request and response handlers are only called if authentication is successful.
request.*
Request configuration (see below for handler specific configuration)
request.handler
Name of request handler (Default: "Pipes"
)
response.*
Response configuration (see below for handler specific configuration)
response.handler
Name of response handler (Default: "Pipes"
)
The request handler is a pluggable component responsible for processing the endpoint HTTP request.
This is the default handler. Converts the API HTTP request to a pipe request containing the body, configured headers and params and request properties.
pipe
Id of pipe implementing the endpoint
headers
List of headers to include in pipe request. (Default: null
, no headers are included)
params
List of parameters (query and/or form) to include in pipe request. (Default: "*"
, all params are included)
session_overload
Flag to enable session overload (i.e use specific session when calling pipes) (Default: false
)
session_id
Name of request parameter containing session id for session overloading. (Default: "__session_id"
)
This request handler proxies request data (i.e. the body) without modifications to a pipe. If request data is a form a new pipe request will be built containing all form params.
The response handler is a pluggable component responsible for producing the endpoint HTTP response.
This is the default handler. Operates on pipe responses that may contain items. Produces a custom response body using a template or returns the pipe response as-is if no template is configured (JSON).
content_type
Response content type
template
Response template (see below)
status
Custom status configuration (see below)
Response handler creating a response from a pipe response containing headers and body properties.
When using the Pipes response handler, the response can be transformed to any text format using a template.
The following object are available during template rendering:
items
List of response items
response
The actual response
util.now
Current date/time as an ISO instant
util.uuid
Create UUID
Pipe response reason can be mapped to a custom HTTP status code by using status mappings.
Mappings are processed in the defined order, first match wins.
regex
Regular expression matched against reason string
value
The HTTP status code returned on match
Attached is the default config.json file used when starting the default configuration.
Since API is based on HTTP all HTTP configuration properties are supported. Find global settings .