LOG IN SIGN UP
Documentation

table.lookup()

Look up the key key in the table ID. When the key is present, its associated value will be returned. When the key is absent, the value returned is not_set.

When a third STRING argument is provided, the lookup function behaves as it would normally, except when a key is absent, the default value is returned instead.

Format

STRING
table.lookup(ID, STRING key [, STRING default])

Examples

1
2
3
4
5
6
7
8
table redirects {
  "/foo": "/bar",
  "/bat": "/baz",
}
set req.http.X-Redirect = table.lookup(redirect_table, req.url);
if (req.http.X-Redirect) {
  error 302 "Found";
}
1
2
3
4
5
6
7
8
table geoip_lang {
  "US": "en-US",
  "FR": "fr-FR",
  "NL": "nl-NL",
}
if (!req.http.Accept-Language) {
  set req.http.Accept-Language = table.lookup(geoip_lang, geoip.country_code, "en-US");
}