Skip to main content

Module vars

Module vars 

Source
Expand description

Request/response variable resolution and condition expressions.

The featherbit analogue of APISIX’s ctx.var + lua-resty-expr: plugins resolve named variables against the Context (uri, arg_<name>, http_<header>, …), interpolate $var / ${var} templates, and evaluate condition expressions written in APISIX’s triple-array form:

vars:
  - ["arg_name", "==", "jack"]
  - ["http_user_agent", "~~", "Mozilla.+"]

Rules in a top-level list are ANDed. A rule is [subject, op, value], the negated [subject, "!", op, value], or unary [subject, "present"|"absent"|"is_null"]. Nested logic uses ["AND", rule...], ["OR", rule...], and ["NOT", rule-or-group] (NOT is a featherbit extension over APISIX’s dialect). Subjects are var names or JSONPath queries over JSON bodies: $.user.name (request body), request_body:$..., response_body:$... — multi-node matches use ANY-semantics. Operators: ==, ~=, >, >=, <, <=, ~~ (regex), ~* (case-insensitive regex), in, has, ipmatch, present, absent, is_null (JSONPath only), contains.

Modules§

catalog
Machine-readable catalog of every variable super::resolve supports — the single source the Admin API (GET /api/vars), the UI autocomplete, and the var legend consume. Guarded against drift from the resolver by test_catalog_matches_resolver, which parses resolve()’s source.
jsonpath
JSONPath subjects for condition expressions: $.user.name (request body), request_body:$..., response_body:$.... Paths are compiled at config load (RFC 9535 via serde_json_path); malformed paths fail policy compilation, not requests.
template
Universal {{namespace.path}} template engine.

Structs§

EvalState 🔒
Per-evaluation state: the context plus lazily-parsed JSON bodies, so a multi-rule expression parses each body at most once per eval.
Expr
A compiled condition expression in APISIX’s triple-array form.

Enums§

Node 🔒
Op 🔒
Subject 🔒
What a rule’s condition is evaluated against: a flat named var, or a JSONPath query over a request/response body.

Functions§

cookie_value 🔒
eval_node 🔒
Evaluates a node left-to-right with short-circuiting. Absent vars evaluate as empty string (absent address for ipmatch), and a JSONPath subject over an empty or unparsable body matches zero nodes.
eval_op 🔒
eval_op_json 🔒
ANY-match: the rule holds if at least one matched node passes. Present/Absent/IsNull are match-set operators, evaluated over the whole node set rather than per-node.
eval_op_json_node 🔒
hex_val 🔒
interpolate
Interpolates $var and ${var} references in a template.
json_scalar_eq 🔒
Native scalar equality: string↔string, number↔number, bool↔bool. null, arrays, and objects never equal a scalar config value.
message_str 🔒
node_references_response_body 🔒
Whether evaluating node reads context.response.body.
parse_node 🔒
post_arg 🔒
query_string 🔒
resolve
Resolves a variable name against the context.
scalar_str 🔒
Stringifies a scalar config value the way the legacy parser did (String as-is, Number/Bool via to_string). None for null/array/object.
split_remote_addr 🔒
Splits ip:port, tolerating bare IPs and bracketed IPv6.
urldecode 🔒