Data Enrichment

The HUMAN Fastly Enforcer provides a hook function where processing is performed on the data enrichment payload

px_custom.vcl contains the custom hook function px_custom_data_enrichment_handler.

The function receives the following headers:

  • X-PX-data-enrichment: A JSON string with data enrichment.
  • X-PX-data-enrichment-validated: A boolean flag indicating when data enrichment is trusted and has not been tampered with (possible values: 0 or 1)

To extract values from the JSON object, set: `req.http.X-PX-de-value = if (req.http.X-PX-data-enrichment ~ {"VALUE_HERE":"([^"]*)"}, re.group.1, "");`

When it is determined that the request should be passed to the backend server, set the X-PX-de-pass-request = "1"

Example:

1px\_custom\_data\_enrichment\_handler {
2
3set req.http.X-PX-de-f-type = if (req.http.X-PX-data-enrichment ~ {"f_type":"([^"]*)"},
4re.group.1, "");
5
6 if (req.http.X-PX-de-f-type == "w") {
7 set req.http.X-PX-de-pass-request = "1";
8 }
9}