General filter information

  • Name: url-extractor-to-header

  • Default Configuration: url-extractor-to-header.cfg.xml

  • Released: v7.3.0.0

  • Bundle: repose-filter-bundle

  • Schema

Prerequisites & Postconditions

Required Request Headers

This filter does not require any request headers.

Required Preceding Filters

While this filter doesn’t require any preceding filter, it’s headers are added to any existing values. If you desire to only get the new values you should use the header normalization filter.

Request Headers Created

This filter will create whatever headers you configure it to.

Request Body Changes

This filter does not make any changes to the request body.

There are no recommended follow on filters for this filter.

Response Body Changes

This filter has zero interactions with the response.

Response Headers Created

This filter has zero interactions with the response.

Response Status Codes

This filter has zero interactions with the response.

Examples

This configuration will exercise all the options available in this filter.

url-extractor-to-header.cfg.xml
<url-extractor-to-header xmlns="http://docs.openrepose.org/repose/url-extractor-to-header/v1.0">
    <extraction header="X-Device-Id" (1)
        url-regex=".*/(hybrid:\d+)/entities/.+" (2)
        default=""/> (3)

    <extraction header="X-Server-Id" url-regex=".*/servers/([^/]+).*"/> (4)

    <extraction header="X-Filter-Param" url-regex=".*\?.*filter=([^&amp;]+).*" default="none"/> (5)
</url-extractor-to-header>
1 The name of the header to populate.
2 The regex to evaluate against the request URL.
At least one capture group is required, though multiple capture groups are supported.
Any captured values will be added to the header.
3 The default value that should be used if the regex misses, in this case it will add an empty value to the header.
4 This example lacks a default, so any regex misses will fo nothing.
5 The default here will add a value of none if the regex fails to capture something.

If a group is used to write a regular expression, but the value of that group should not be added to the header, a non-capturing group construct may be used. For more information, see the special constructs portion of the Java Pattern documentation.

Additional Information

The regexes used in this filter are backed by a Java implementation. You can learn more here.

A regular expression is considered to be matching if it matches any substring of the request URL. A regular expression does not have to match the entire request URL to be considered matching. If a regular expression should match the entire request URL, use boundary matchers (e.g., ^ and $). For example, the regular expression ^/foo/bar$ will only be considered matching if it matches the entire request URL.