URL Extractor to Header


The URL Extractor to Header filter can extract a portion of the request URL and put it in a header in the request.

General filter information

Filter name: url-extractor-to-header

Filter configuration: url-extractor-to-header.cfg.xml



Headers: None

Preceding filters: None

Basic configuration

  1. To enable this filter, add it to the system model.
    1. Add <filter name="url-extractor-to-header"/> to the list of filters in system-model.cfg.xml
  2. Create a url-extractor-to-header.cfg.xml file in /etc/repose with the desired configuration.


Basic [filter name] configuration
 <?xml version="1.0" encoding="UTF-8"?>
<url-extractor-to-header xmlns="http://docs.openrepose.org/repose/url-extractor-to-header/v1.0">
    <!-- Grab the Device ID from the path immediately preceding 'entities'; default to an empty header -->
    <extraction header="X-Device-Id" url-regex=".*/(hybrid:\d+)/entities/.+" default=""/>

    <!-- Grab the Server ID from the resource immediately following 'servers'; don't include header if URL doesn't match -->
    <extraction header="X-Server-Id" url-regex=".*/servers/([^/]+).*"/>

    <!-- Grab the filter parameter; default to 'none' if a filter wasn't supplied -->
    <extraction header="X-Filter-Param" url-regex=".*\?.*filter=([^&amp;]+).*" default="none"/>

Configurable parameters

XML schema definition

Example configuration


The url-extractor-to-header.cfg.xml file contains the following elements and attributes. Add the filter to your Repose deployment through the system model configuration.




<url-extractor-to-header>-RequiredSpecifies the sub-elements and attributes to define your filter configuration.
<extraction>-RequiredElement to configure a URL extraction to a header.
headerRequiredThe name of the header to create.
url-regexRequiredThe regular expression to apply to the URL to get the header value.
defaultOptionalIf this attribute is not present and the URL doesn't match the url-regex, the header will not be created.
If this attribute is present and the URL doesn't match the url-regex, the header will be created using the value of this attribute.
If the URL does match the url-regex, this value is not used.

Return codes and conditions

This filter does not impact the response and should not cause an abrupt end of processing.

Request headers created

This filter will create the configured headers except in the case where the url-regex does not match the request URL and a default value is not specified.