The IBM Application Gateway has a new home - docs.verify.ibm.com/gateway
The documentation on this site will no longer be maintained after v21.02, please update your bookmarks.
The IAG provides the ability to insert content into HTTP responses for a specified URI. This is commonly referred to as content injection.
The following diagram outlines content injection processing:
The available configuration options are defined in the Content Injection YAML reference.
The location can be either matched against a full line in the response, or any specific text in the response. This is controlled by the 'full_line_match' configuration entry.
- The location can be pattern matched against a line in the response using the '*' and '?' wildcard characters;
- The maximum length of a line which can be matched by this mechanism is 8192 bytes;
- The pattern match is case-sensitive.
The content is then inserted immediately before the matching line.
- You must include a new line character at the end of the content if you want it to be inserted as a separate line. Otherwise, IAG adds the content to the start of the matching line.
- An exact match is required when performing a partial line match. In other words, pattern matching characters are not supported.
- The text comparison is case-sensitive.
The content can either be inserted immediately prior to the matching text, or it can replace the matching text. This is controlled by the 'replace_match' configuration entry.
Using a simple HTML page:
<html> <body> Insert content before here: Data More data </body> </html>
The following example will insert a line of text before the string 'Insert content before here':
policies: content_injection: - name: inject_text paths: - "/myapp/sampleResource.html" location: "Insert content before here*" content: "<hr/>This text was injected using content injection.<hr/>"
Requests to https://<IAG container>/myapp/sampleResource.html will return a HTML page that contains the injected content.
<html> <body> <hr/>This text was injected using content injection.<hr/>Insert content before here: Data More data </body> </html>