StaticRequestFilter
Creates a new request, replacing any existing request. The request can include an entity specified in the entity
parameter. Alternatively, the request can include a form, specified in the form
parameter, which is included in an entity encoded in application/x-www-form-urlencoded
format if request method is POST
, or otherwise as (additional) query parameters in the URI. The form
and entity
parameters cannot be used together when the method
is set to POST
.
Usage
{ "name": string, "type": "StaticRequestFilter", "config": { "method": string, "uri": runtime expression<uri string>, "version": string, "headers": { configuration expression<string>: [ runtime expression<string>, ... ], ... }, "form": { configuration expression<string>: [ runtime expression<string>, ... ], ... }, "entity": runtime expression<string> } }
Properties
"method"
: string, requiredThe HTTP method to be performed on the resource (for example,
"GET"
)."uri"
: runtime expression<uri string>, requiredThe fully-qualified URI of the resource to access (for example,
"http://www.example.com/resource.txt"
).The result of the expression must be a string that represents a valid URI, but is not a real
java.net.URI
object. For example, it would be incorrect to use${request.uri}
, which is not a String but a MutableUri."version"
: string, optionalProtocol version. Default:
"HTTP/1.1"
."headers"
: object, optionalHeader fields to set in the request, with the format
name: [ value, ... ]
.The
name
field ofheaders
specifies the header name. It can be defined by a configuration expression or string. If the configuration expressions for multiplename
resolve to the same final string, multiple values are associated with thename
.The
value
field ofheaders
is an array of runtime expressions to evaluate as header values.In the following example, the name of the header is the value of the configuration time, system variable defined in
cookieHeaderName
. The value of the header is the runtime value stored incontexts.ssoToken.value
:"headers": { "${application['header1Name']}": [ "${application['header1Value'}" ]
"form"
: object, optionalA form to include in the request, with the format
param: [ value, ... ]
.The
param
field ofform
specifies the name of the form parameter. It can be defined by a configuration expression or string. If the configuration expressions for multipleparam
resolve to the same final string, multiple values are associated with theparam
.The
value
field ofform
is an array of runtime expressions to evaluate as form field values.When the
method
is set toPOST
, this setting is mutually exclusive with theentity
setting.In the following example, the names of the field parameters and the values are hardcoded in the form:
"form": { "username": [ "demo" ], "password": [ "Ch4ng31t" ]
In the following example, the names of the field parameters are hardcoded. The values take the first value of
username
andpassword
provided in the session:"form": { "username": [ "${session.username[0]}" ], "password": [ "${session.password[0]}" ]
In the following example, the name of the first field param take the value of the expression
${application['formName']}
when it is evaluated at startup. The values take the first value ofusername
andpassword
provided in the session:"form": { "${application['formName']}": [ "${session.username[0]}" ], "${application['formPassword']}": [ "${session.password[0]}" ]
"entity"
: runtime expression<string>, optionalThe entity body to include in the request.
This setting is mutually exclusive with the
form
setting when themethod
is set toPOST
.See also "Expressions".
Example
In the following example, IG replaces the browser's original HTTP GET request with an HTTP POST login request containing credentials to authenticate to the sample application. For information about how to set up and test this example, see Getting Started Guide.
{ "handler": { "type": "Chain", "config": { "filters": [ { "type": "StaticRequestFilter", "config": { "method": "POST", "uri": "http://app.example.com:8081/login", "form": { "username": [ "demo" ], "password": [ "Ch4ng31t" ] } } } ], "handler": "ReverseProxyHandler" } }, "condition": "${matches(request.uri.path, '^/static')}" }