haproxy/doc
Willy Tarreau 54496a6a5b MINOR: vars: make the vars() sample fetch function support a default value
It is quite common to see in configurations constructions like the
following one:

    http-request set-var(txn.bodylen) 0
    http-request set-var(txn.bodylen) req.hdr(content-length)
    ...
    http-request set-header orig-len %[var(txn.bodylen)]

The set-var() rules are almost always duplicated when manipulating
integers or any other value that is mandatory along operations. This is
a problem because it makes the configurations complicated to maintain
and slower than needed. And it becomes even more complicated when several
conditions may set the same variable because the risk of forgetting to
initialize it or to accidentally reset it is high.

This patch extends the var() sample fetch function to take an optional
argument which contains a default value to be returned if the variable
was not set. This way it becomes much simpler to use the variable, just
set it where needed, and read it with a fall back to the default value:

    http-request set-var(txn.bodylen) req.hdr(content-length)
    ...
    http-request set-header orig-len %[var(txn.bodylen,0)]

The default value is always passed as a string, thus it will experience
a cast to the output type. It doesn't seem userful to complicate the
configuration to pass an explicit type at this point.

The vars.vtc regtest was updated accordingly.
2021-09-03 12:08:54 +02:00
..
design-thoughts DOC: assorted typo fixes in the documentation 2020-03-09 14:45:58 +01:00
internals CLEANUP: assorted typo fixes in the code and comments 2021-08-16 12:37:59 +02:00
lua-api CLEANUP: assorted typo fixes in the code and comments 2021-08-25 05:13:31 +02:00
51Degrees-device-detection.txt CONTRIB: move 51Degrees to addons/51degrees 2021-04-02 17:48:42 +02:00
DeviceAtlas-device-detection.txt CONTRIB: move src/da.c and contrib/deviceatlas to addons/deviceatlas 2021-04-02 17:48:42 +02:00
SOCKS4.protocol.txt
SPOE.txt CLEANUP: assorted typo fixes in the code and comments 2021-08-16 12:37:59 +02:00
WURFL-device-detection.txt CONTRIB: move src/wurfl.c and contrib/wurfl to addons/wurfl 2021-04-02 17:48:42 +02:00
acl.fig
architecture.txt DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments 2021-05-09 06:50:46 +02:00
close-options.txt MINOR: config: reject long-deprecated "option forceclose" 2021-06-11 16:57:34 +02:00
coding-style.txt DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments 2021-05-09 06:50:46 +02:00
configuration.txt MINOR: vars: make the vars() sample fetch function support a default value 2021-09-03 12:08:54 +02:00
cookie-options.txt
gpl.txt
haproxy.1 DOC: add description of pidfile in master-worker mode 2020-08-26 18:40:53 +02:00
intro.txt DOC: intro: Fix typo in starter guide 2021-05-27 08:26:43 +02:00
lgpl.txt
linux-syn-cookies.txt
lua.txt [RELEASE] Released version 2.4-dev19 2021-05-10 07:50:26 +02:00
management.txt MEDIUM: vars: also support format strings in CLI's "set var" command 2021-09-03 11:01:48 +02:00
netscaler-client-ip-insertion-protocol.txt
network-namespaces.txt
peers-v2.0.txt DOC: peers: fix the protocol tag name in the doc 2021-05-09 06:38:07 +02:00
peers.txt
proxy-protocol.txt DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments 2021-05-09 06:50:46 +02:00
queuing.fig
regression-testing.txt DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments 2021-05-09 06:50:46 +02:00
seamless_reload.txt