lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> if method in ('HEAD','GET','POST') then ...

Can you use table lookups?

(global)
method_table = {
   ["HEAD"] = HeadFunction,
   ["GET"] = GetFunction,
   ["POST"] = PostFunction
   }


(local)
fnc = method_table[method]

res = fnc(bytes, other_params)

(end)

I use this approach to handle calling functions based on the string value.

tim

Gregory T. (tim) Kelly
Owner
Dialectronics.com


"Anything war can do, peace can do better."  -- Bishop Desmond Tutu