Interface RequestTransform

interface RequestTransform {
    matchReplaceBody?: [string | RegExp, string][];
    patchJsonBody?: Operation[];
    replaceBody?: string | Uint8Array | Buffer;
    replaceBodyFromFile?: string;
    replaceHeaders?: Headers;
    replaceMethod?: string;
    updateHeaders?: Headers;
    updateJsonBody?: {
        [key: string]: any;
    };
}

Properties

matchReplaceBody?: [string | RegExp, string][]

Perform a series of string match & replace operations on the request body.

This parameter should be an array of pairs, which will be applied to the body decoded as a string like body.replace(p1, p2), applied in the order provided. The first parameter can be either a string or RegExp to match, and the second must be a string to insert. The normal str.replace $ placeholders can be used in the second argument, so that e.g. $1 will insert the 1st matched group.

patchJsonBody?: Operation[]

A series of operations to apply to the request body in JSON Patch format (RFC 6902).

Any requests which are received with an invalid JSON body that match this rule will fail.

replaceBody?: string | Uint8Array | Buffer

A string or buffer that replaces the request body entirely.

If this is specified, the upstream request will not wait for the original request body, so this may make responses faster than they would be otherwise given large request bodies or slow/streaming clients.

replaceBodyFromFile?: string

The path to a file, which will be used to replace the request body entirely. The file will be re-read for each request, so the body will always reflect the latest file contents.

If this is specified, the upstream request will not wait for the original request body, so this may make responses faster than they would be otherwise given large request bodies or slow/streaming clients.

replaceHeaders?: Headers

A headers object which will completely replace the real request headers.

replaceMethod?: string

A replacement HTTP method. Case insensitive.

updateHeaders?: Headers

A headers object which will be merged with the real request headers to add or replace values. Headers with undefined values will be removed.

updateJsonBody?: {
    [key: string]: any;
}

A JSON object which will be merged with the real request body. Undefined values will be removed, and other values will be merged directly with the target value recursively.

Any requests which are received with an invalid JSON body that match this rule will fail.