# Add a response header

Add a response header based on the visitor's country, resolved from GeoIP data on Azion's global network. Use this pattern in a firewall function to tag or flag traffic from specific regions, for example to drive country-specific logic downstream without blocking the request.

```js
async function firewallHandler(event){
    // Access the country code through geoip
    let countryCode = event.request.metadata["geoip_country_code"]

    // Do some logic here
    // In this example, if the request comes from Brazil, we add a header to the response
    if (countryCode === "BR"){
        event.addResponseHeader("test", "true");
    }

    // Then, if it comes from any other country,
    // the processing continues
    event.continue();
}

addEventListener("firewall", (event)=>event.waitUntil(firewallHandler(event)));
```

## How it works

This code runs as a `firewall` handler, so it executes in a firewall and not in the application request path. It registers the handler with `addEventListener("firewall", ...)` and wraps the asynchronous work in `event.waitUntil()`, so processing completes before the event ends. Refer to [Functions for Firewall](/en/documentation/platform/firewall/functions/) for the full set of actions a firewall handler can call.

The handler reads the country code from `event.request.metadata["geoip_country_code"]`, and when the visitor is from Brazil it calls `event.addResponseHeader("test", "true")` to attach a custom header to the response. It ends with `event.continue()`, which lets the request proceed to its destination instead of being blocked.

## Related resources

- [JavaScript examples](/en/documentation/platform/functions/javascript-examples.md): Browse the other syntax patterns in the collection.
- [Functions for Firewall](/en/documentation/platform/firewall/functions.md): Read the reference for every action a firewall handler can call.
- [Metadata API](/en/documentation/devtools/runtime/api-reference/metadata.md): Look up the request metadata fields, including the GeoIP values.
- [Functions Instances for Firewall](/en/documentation/platform/firewall/functions-instances.md): See how a function is instantiated on a firewall and triggered by a rule.
- [Scope and limits](/en/documentation/platform/functions.md#scope-and-limits): The languages, runtime, and execution contexts a function is written against.
