On Fri, 11 Dec 2015 17:05:16 -0800
Hugues Alary <[email protected]> wrote:

> Hi there,
> 
> I'm trying my hands on haproxy 1.6.2 and I'm excited about the LUA
> integration.
> 
> I'm however running into an issue and can't figure out why. Please forgive
> me if my issue is only due to my complete ignorance about LUA (I literally
> just opened the language documentation).
> 
> I'm trying to call the txn:get_headers() function, but when doing so, I get
> the following error in my logs: "Lua function 'myFunc': runtime error:
> /etc/haproxy/hello_world.lua:2: attempt to call a nil value (method
> 'get_headers')."


Hi,

This is strange: Lua says that you try to "call a nil value" when you
try to execute a funciton which doesn't exists.

In your case, the fucntion exists. You can dump the full stuct of the
"txn" var with the function below:

   http://ww.arpalert.org/haproxy-scripts.html#print_r

Just add "print_r(txn)", and you will be fixed about the content of the
object "txn".

I read the haproxu luacode to be sure of the existence of these
function, and I sew that it was renamed. So, try the function:

   req_get_headers()

The API doc:

   http://www.arpalert.org/src/haproxy-lua-api/1.7dev/#txn-class

Thierry.


> function myFunc(txn)
>   txn:get_headers()
> end
> 
> core.register_action("myFunc", { "http-req" }, myFunc);
> 
> Is this a bug, or just me not knowing what I'm doing?
> 
> It's worth noting that calling: txn:done() works.
> 
> Sincerely,
> -Hugues

Reply via email to