Elffuss BraidHub

kikocis/EDC public

Changeset: cc2a9ff178c4
cc2a9ff178c4 fix: return StsClient from create() (#4479) Paul Latzelsperger,
..
src/
README.md5.3 KiB
build.gradle.kts1.2 KiB

README.md

Data Plane HTTP extension

Background

Scope

This extension provides support for sending data sourced from an HTTP endpoint and posting data to an HTTP endpoint. By nature of the DPF design, which supports n-way transfers, HTTP-sourced data can be sent to any DataSink type and an HTTP endpoint can receive data from any DataSource type. The extension is designed to stream content to limit memory consumption under load.

Use Cases

Typically, this extension is used to fetch or post data from/to a REST endpoint.

Technical Details

Dependencies

NameDescription
extensions:data-plane:data-plane-spiSPI of the data plane

Provided Services

HttpRequestParamsProvider

This service could be used to register HTTP params decorators (implementors of HttpParamsDecorator), that will be invoked before the HTTP request creation, both on source and on sink sides. This can be useful, to enhance the request adding some headers with for example some data flow related info like "transferId" or "contractId".

To register a decorator, you can inject the HttpRequestParamsProvider and use one of the register methods:

  • registerSourceDecorator: register the decorator that will be used for every source request
  • registerSinkDecorator: register the decorator that will be used for every sink request

Example:

public class CustomDecoratorExtension implements ServiceExtension {
    
    @Inject
    private HttpRequestParamsProvider paramsProvider;
    
    public void initialize(ServiceExtensionContext context) {
        paramsProvider.registerSourceDecorator((request, address, builder) -> builder.header("customSourceHeader", "customValue"));
        paramsProvider.registerSinkDecorator((request, address, builder) -> builder.header("customSinkHeader", "customValue"));
    }
}

Design Principles

This extension provides implementations for HttpDataSourceFactory, HttpDataSinkFactory, HttpDataSource and HttpDataSink, which are triggered when the DataFlowRequest type is HttpData.

Basically the role of these classes is to extract the parameters (query params, path, body, auth header...) required to hit the HTTP endpoint and then to perform the call.

The table below summarizes how each parameter is retrieved for the source/sink implementations.

ParameterHttpDataSourceHttpDataSinkExample
Base urlSource/destination DataAddressSamehttp://example.com
Authorization header keySource/destination DataAddressSameApi-Key
Authorization header codeSource/destination DataAddress, which can either contains the secret value, or the Vault secret nameSame8e631012-f6de-11ec-b939-0242ac120002
HeadersSource/destination DataAddressSamefoo:bar;hello:world
PathDataFlowRequest properties if path proxy enabled by the source DataAddressDestination DataAddressfoo/bar
Query paramsDataFlowRequest properties if query param proxy enabled by the source DataAddressDestination DataAddresshello=world&foo=bar
MethodDataFlowRequest properties if method proxy enabled by the source DataAddress, otherwise default to GETDestination DataAddress if present, otherwise POST by defaultGET, POST...
Content typeDataFlowRequest properties if body proxy enabled by the source DataAddressDestination DataAddressapplication/json
BodyDataFlowRequest properties if body proxy enabled by the source DataAddressPart stream fetched by the DataSource"hello world!"
NonChunkedTransferNot usedDestination DataAddress if present, otherwise true by default"false"