mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-05 13:23:32 +02:00
MINOR: hlua: Allow argument on lua-lod(-per-thread) directives
Allow per-lua file argument which makes multiples configuration easier to handle This patch fixes issue #1609.
This commit is contained in:
committed by
Christopher Faulet
parent
70e38e91b4
commit
ae6b56800f
@@ -116,6 +116,38 @@ On other terminal, you can test with telnet:
|
||||
#:~ telnet 127.0.0.1 10001
|
||||
hello world
|
||||
|
||||
Usage of load parameters
|
||||
------------------------
|
||||
|
||||
HAProxy lua-load(-per-thread) directives allow a list of paramaters after
|
||||
the lua file name. These parameters are accessible through an array of args
|
||||
using this code `local args = table.pack(...)` in the body of loaded file.
|
||||
|
||||
Below, a new version of the hello world using load parameters
|
||||
|
||||
HAProxy configuration file (`hello_world.conf`):
|
||||
|
||||
::
|
||||
|
||||
global
|
||||
lua-load hello_world.lua "this is not an hello world"
|
||||
|
||||
listen proxy
|
||||
bind 127.0.0.1:10001
|
||||
tcp-request inspect-delay 1s
|
||||
tcp-request content use-service lua.hello_world
|
||||
|
||||
HAProxy Lua file (`hello_world.lua`):
|
||||
|
||||
.. code-block:: lua
|
||||
|
||||
local args = table.pack(...)
|
||||
|
||||
core.register_service("hello_world", "tcp", function(applet)
|
||||
applet:send(args[1] .. "\n")
|
||||
end)
|
||||
|
||||
|
||||
Core class
|
||||
==========
|
||||
|
||||
|
||||
Reference in New Issue
Block a user