# Install Process Request Data Into Headers

**Process Request Data Into Header** is a *serverless* integration available at Azion Marketplace. 

The purpose of this function is to stop a request whenever a request body field is empty. Using regex, the user can validate not only whether the field exists but also patterns. Additionally, they have the option to use any behavior they choose rather than a predetermined `Deny Request`.

---

## Getting the integration

To install the integration, follow these steps:

1. Access [Azion Console](/en/documentation/products/guides/how-to-access-azion-console/) > **Marketplace**.
2. On the Marketplace homepage, select the integration's card.
3. Once the integration's page opens, click the **Install** button.

You'll see a message indicating that your integration was successfully installed.

:::tip
You can search any integration by browsing through the cards, using the filters, or typing a keyword in the search bar.
:::

---

## Configuring the integration

### Setting up a firewall

To instantiate the **Process Request Data Into Header** integration, follow the steps:

1. On the **Products menu**, select **Firewall** in the **SECURE** section.
2. Click the **+ Firewall** button.
3. Give an easy to remember name to your firewall.
4. Turn the **Functions** switch on.
5. Click the **Save** button.

Done. Now you have instantiated the rule for your function.

### Setting up the integration

To instantiate the **Process Request Data Into Header** integration, while still on the **Firewall** page:

1. Select the **Functions Instances** tab and follow these steps:
2. Click the **+ Function Instance** button.
3. Give an easy to remember name to your instance.
4. On the dropdown menu, select the **Process Request Data Into Header** function.
    - This function doesn't address any argument on the **Arguments** tab, but you can test it using the `curl` command.

### Curl command examples

| Curl Command                                                                                                                                                                | Request headers added by the function                                                                |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| `curl https://mydomain/function`                                                                                                                                            | `X-Body-Error": "CT001`                                                                              |
| `curl -H "Content-Type: application/x-www-form-urlencoded" --request POST --data 'param1=v1&param2=v2&param3=v3' https://mydomain/function`                                | `X-Body-Param1": "v1"` <br /> `X-Body-Param2": "v2"` <br /> `X-Body-Param3": "v3"`                                 |
| `curl -H "Content-Type: application/json" --request POST --data '{"my_data": {"abc": {"def": {"g": "xyz","h": false,"e": null}}, "number": 1}}' https://mydomain/function` | `X-Body-My-Data-Abc-Def-G": "xyz"` <br /> `X-Body-My-Data-Abc-Def-H": "false"` <br />`X-Body-My-Data-Number": "1"` |
| `curl -H "Content-Type: text/plain" --request POST --data 'plain=text' https://mydomain /function`                                                                         | `X-Body-Error": "CT002"`                                                                             |
| `curl -H "Content-Type: application/json" --request POST --data '{"my_data": {"abc": {"def": {"g": "xyz","h": false,"e": null}}, "number": 1}' https://mydomain/function`  | `X-Body-Error": "FD001"`                                                                             |

:::note
As long as the request has a valid `Content-Type` header and a valid request body, the integration converts the body fields into headers. This integration also supports nested object data. In this case, each "level" will be separated by a hyphen.
:::

#### Possible errors

This integration can trigger errors. In this case, the errors will be appended to a new header called `X-Body-Error`.

| Error Code | Description                                                                    |
|------------|--------------------------------------------------------------------------------|
| `CT001`    | The header `Content-Type` is missing or it's null |
| `CT002`    | The header `Content-Type` has a value, but it isn't supported by the function |
| `FD001`    | The request body isn't correctly formatted and couldn't be decoded |

## Setting up the Firewall Rules Engine

To finish, you have to set up the [Rules Engine](/en/documentation/products/secure/firewall/rules-engine/) to configure the *behavior* and the *criteria* to run the integration.

Still in the **Firewall** page:

1. Select the **Rules Engine** tab.
2. Click the **+ Rule Engine** button.
3. Give a name to the rule.
4. Select a *criteria* to run and catch the domains that you want to run the integration on.
  - Example: if `Host` *matches* `yourdomain.com`.
5. Below, select a *behavior* to the *criteria*. In this case, it'll be **Run Function**. 
    - Select the adequate function according to the name you gave it during the instantiation step.
6. Click the **Save** button.

On the Console, you must now configure your domain so your firewall protects it.

7. On the **Products menu**, select **Workloads**.
8. Click on the domain you want to protect with your IP Process Request Data Into Header.
9. In the **Settings** section, click on the `Firewall` selector and choose the firewall you created.
10. Click the **Save** button.

Done. Now the **Process Request Data Into Header** integration is running for every request made to the domain you indicated.

---