From: Thierry FOURNIER Date: Thu, 1 Oct 2015 13:00:42 +0000 (+0200) Subject: DOC: lua: update doc according with the last Lua changes X-Git-Tag: v1.6-dev7~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a2d02253cfac4bd6c9b533d5dae075dc4d8c57bd;p=thirdparty%2Fhaproxy.git DOC: lua: update doc according with the last Lua changes The impact of the register_action() was not repported. --- diff --git a/doc/lua-api/index.rst b/doc/lua-api/index.rst index 54eae8fa8c..05f222c957 100644 --- a/doc/lua-api/index.rst +++ b/doc/lua-api/index.rst @@ -43,11 +43,9 @@ functions. Lua have 6 execution context. like this: `function fcn()`. 4. The **action context**. It is an Lua function conditionally executed. These - actions are declared by the HAProxy directives "`tcp-request content lua - `", "`tcp-response content lua `", "`http-request lua - `" and "`http-response lua `". The prototype of the - Lua called function is a function with doesn't returns anything and that take - an object of class TXN as entry. `function fcn(txn)` + actions are registered by the Lua directives "`core.register_action()`". The + prototype of the Lua called function is a function with doesn't returns + anything and that take an object of class TXN as entry. `function fcn(txn)`. 5. The **sample-fetch context**. This function takes a TXN object as entry argument and returns a string. These types of function cannot execute any @@ -80,16 +78,16 @@ HAProxy configuration file (`hello_world.conf`): listen proxy bind 127.0.0.1:10001 - tcp-request content lua hello_world + tcp-request inspect-delay 1s + tcp-request content use-service lua.hello_world HAProxy Lua file (`hello_world.lua`): .. code-block:: lua - function hello_world(txn) - txn.res:send("hello world\n") - txn:done() - end + core.register_service("hello_world", "tcp", function(applet) + applet:send("hello world\n") + end) How to start HAProxy for testing this configuration: