Nav

To Add or Remove Header Policies

If you have configured custom policies in Anypoint Platform, the process is basically the same for add or remove header policies. The following steps show how to set up and apply the policies in Anypoint Platform.

To add or remove header policies, you first need to perform some set up:

  1. Go to API Manager > API Administration.

  2. Click Custom Policies.

    Custom Policies appears listing custom policies, if there are any, that are available for the API.

  3. Click Add Custom Policy.

  4. Select the Mule Runtime Version you use to deploy the API.

  5. In Name, enter a name for the policy, for example add request header policy.

  6. In Policy Definition, click Choose File to locate the YAML file, add-request.yaml in this example, that you downloaded.

  7. In Policy Configuration, choose the XML file, for example, add-request.xml, that you downloaded.

  8. Click Add.

    The policy, add request header policy in this example, appears on the Custom Policies page. gw-custom-pol-list

Applying the Add Request/Response Header Policies

Continuing with example of the add request header policy, follow steps in this procedure to apply either of the following policies:

  • Add request header policy

  • Add response header policy

To apply add the request header policies or add response header policies:

  1. Assuming you already deployed the API version, select the instance in API Administration.

  2. On the API dashboard, select Policies from the list of items.

    The Add Request Header Policy, for example, appears in the Available Policies list.

    If the header was already provided by the client or another policy, the value is overwritten by the one you provide in this policy.

  3. Click Apply.

    The Apply Add Request Header Policy dialog box appears.

  4. Type the name and value of a header. For example, type extra-header on the left and myvalue on the right.

  5. Optionally, include expressions in the value of the header.

    For example, include the following expression to substitute the name of the user-agent in the header text.

    '#[message.inboundProperties['user-agent']]'

  6. Click gw-apply-pol-plus-icon.

  7. Optionally add more names and values of headers to add in the same manner, and click Apply.

    The policy you applied moves from the Available Policies list to the Applied Policies list.

Applying the Remove Request/Response Header Policies

Perform the steps in this procedure to apply either of the following policies:

  • Remove request header policy

  • Remove response header policy

To apply the remove request header or remove response header policies:

  1. On API dashboard, select Policies from the list of items.

    The policy, Remove Request Header Policy in this example, appears in the Available Policies list.

    If the header was already provided by the client or another policy, the value is overwritten by the one you provide in this policy.

  2. Click Apply.

    The Apply Remove Request Headers Policy dialog appears.

  3. Type the name of each header that you want to remove, separated by commas.

    You can use wildcards to remove properties that have similar names. For example, using foo-*` will remove foo-bar, foo-test.

  4. Click Apply.

    The policy you applied moves from the Available Policies list to the Applied Policies list.