Selection is the mechanism for conditional operation. This is done by specifying the extraction of a
feature then applying comparisons. Each cmparison has an associated list of directives
which is invoked if the comparison is successful. The
with directive is used for
selection. The key
select is used to anchor the list of comparisons.
with: ua-req-host select: - match: "mail.example.one" do: - proxy-req-url: "https://example.com/mail" - match: "search.example.one" do: - proxy-req-url: "https://engine.example.one"
ua-req-host is an extractor that extracts the host of the URL in the client request.
The value of the
select key is a list of objects which consist of a comparison and a list of
directives as the value of the
match is a comparison operator that does string comparisons between its
value and the active feature. The directive
proxy-req-url sets upstream destination in
the proxy request. What this configuration snippet does is change requests for “mail.example.one” to
requests to “example com/mail” and requests for “search.example.on” to “engine.example.one”.
select mechanism is a directive and so selection can be nested to an
arbitrary depth. Each selection can be on a different feature. As result the relative importance of
features is determined by the particular configuration. This means decisions can be made in a
hierarchial style rather than a single linear set of rules, which enables a large reduction in “cross
talk” between rules.