Headers will be forwarded forth and back between the DDN engine and data connectors:
Client -> DDN Engine -> Data Connector: is usually used for forwarding Cookie or OAuth2 access tokens from clients.Data Connector -> DDN Engine -> Client: forward headers from the external HTTP execution back to the client.
- Enable
forwardHeadersin theconfig.yamlfile of the connector directory, and define the name of theheadersargument field.
# ...
forwardHeaders:
enabled: true
argumentField: headers- Introspect the connector to update the relevant schema.
ddn connector introspect \<connector-name\>- Finally, add the headers argument, which you defined above, to the
argumentPresetsinDataConnectorLinkmetadata with allowed HTTP headers. For instance:
kind: DataConnectorLink
version: v1
definition:
name: my_api
# ...
argumentPresets:
- argument: headers
value:
httpHeaders:
forward:
- Cookie
additional: {}- Enable
forwardHeadersin theconfig.yamlfile of the connector directory, and configureresponseHeaders.headersFieldandresultFieldfield wrappers will be added in the connector schema.forwardHeadersarray is allowed headers that will be forwarded back.
# ...
forwardHeaders:
enabled: true
responseHeaders:
headersField: headers
resultField: response
forwardHeaders:
- X-Test-Header
- X-Test-ResponseHeader- Introspect the connector to update the relevant schema.
ddn connector introspect \<connector-name\>- Finally, add the exact
responseHeadersobject which you defined above toDataConnectorLinkmetadata. For instance:
kind: DataConnectorLink
version: v1
definition:
name: my_api
# ...
responseHeaders:
headersField: headers
resultField: response
forwardHeaders:
- X-Test-Header
- X-Test-ResponseHeaderYou can use a Pre-NDC Request Plugin to modify the request, and add dynamic headers in runtime via request_arguments.headers field, which is a string map. Those headers will be merged into the HTTP request headers before being sent to external services.
See the full example at Pre-NDC Request Plugin Request
{
// ...
"ndcRequest": {
// ...
"request_arguments": {
"headers": {
"Authorization": "Bearer <token>",
"X-Custom-Header": "foo"
}
}
}
}