The SDK Proxy allows a DFSP to use the same outbound SDK endpoint for talking to a DFSP through the Mojaloop API and to a non-Mojaloop (custom) REST API exposed by the Mojaloop Hub. For example:
- to issue a Mojaloop transfer request, a DFSP would call:
http://local.sdk-adapter.com:4001/transfers
- to issue a request to a custom API, a DFSP would call:
http://local.sdk-adapter.com:4001/customservice
To be able to connect to a custom API, the DFSP must:
- Define API endpoint information in a Proxy configuration YAML file.
- Specify the location of the configuration file in the environment variable
PROXY_CONFIG_PATH
. - Map the configuration file into the container at runtime.
The configuration file is structured as follows:
version: 1.0
routes:
- description: 'Routing by URL path as string'
match:
- path: /sdk-path-1
- path: /sdk-other-path-1
destination:
path: /switch-path-1
- description: 'Routing by URL path as regexp'
match:
- path: ~ ^\/sdk-.*2$
destination:
path: /switch-path-2
- description: 'Routing by query and headers params with regexp'
match:
- path: /sdk-custom-api
headers:
- name: CustomHeader
value: ~ *
query:
- key: customQueryKey
value: Value1
- key: ~ query.*Special
value: ~ val.*2
destination:
path: /switch-path-3
-
version
(required) - Must be set to1.0
. -
routes
(required) - Must contain an array of routes, that is, endpoint mappings with corresponding forwarding rules.
-
description
(optional) - User description of route. -
match
(required) - Must contain one or more forwarding rules that will be applied to incoming requests. A request will be forwarded to thedestination
if ANY of the rules match the request. -
destination
(required) - The endpoint that the SDK Proxy should forward requests to.
There must be at least one forwarding rule defined in match
, additional rules are optional.
A forwarding rule value can be defined as a plain string or a regular expression.
When using a regular expression, the value must be prefixed with the tilde symbol (~
) and a space, for example:
~ customVal.*
~ ^\/api\/common\/.*\/v1$
A forwarding rule is applied by the SDK Proxy when ALL of the items inside the rule match the corresponding request parameters (such as an endpoint URL, or HTTP request headers, or query parameters). You can define rules about request parameters using the following elements in the configuration file:
-
path
- used to match a URL path -
headers
- array ofname
/value
pairs used to match HTTP request headers:name
- HTTP header namevalue
- HTTP header value
-
query
- array ofkey
/value
pairs used to match HTTP query parameters:key
- HTTP query keyvalue
- HTTP query value