mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-07 09:42:34 +00:00
DOC: lua: update doc according with the last Lua changes
The impact of the register_action() was not repported.
This commit is contained in:
parent
7dd784b525
commit
a2d02253cf
@ -43,11 +43,9 @@ functions. Lua have 6 execution context.
|
|||||||
like this: `function fcn()`.
|
like this: `function fcn()`.
|
||||||
|
|
||||||
4. The **action context**. It is an Lua function conditionally executed. These
|
4. The **action context**. It is an Lua function conditionally executed. These
|
||||||
actions are declared by the HAProxy directives "`tcp-request content lua
|
actions are registered by the Lua directives "`core.register_action()`". The
|
||||||
<function>`", "`tcp-response content lua <function>`", "`http-request lua
|
prototype of the Lua called function is a function with doesn't returns
|
||||||
<function>`" and "`http-response lua <function>`". The prototype of the
|
anything and that take an object of class TXN as entry. `function fcn(txn)`.
|
||||||
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
|
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
|
argument and returns a string. These types of function cannot execute any
|
||||||
@ -80,16 +78,16 @@ HAProxy configuration file (`hello_world.conf`):
|
|||||||
|
|
||||||
listen proxy
|
listen proxy
|
||||||
bind 127.0.0.1:10001
|
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`):
|
HAProxy Lua file (`hello_world.lua`):
|
||||||
|
|
||||||
.. code-block:: lua
|
.. code-block:: lua
|
||||||
|
|
||||||
function hello_world(txn)
|
core.register_service("hello_world", "tcp", function(applet)
|
||||||
txn.res:send("hello world\n")
|
applet:send("hello world\n")
|
||||||
txn:done()
|
end)
|
||||||
end
|
|
||||||
|
|
||||||
How to start HAProxy for testing this configuration:
|
How to start HAProxy for testing this configuration:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user