currently you need to wrap the lua blocks in a function:

<LuaHookTranslateName my_function_to_call>
require 'apache2'

function my_function_to_call(r)
  if r.uri == "/translate-name" then
    r.uri = "/find_me.txt"
    return apache2.DECLINED
  end
  return apache2.DECLINED
end
</LuaHookTranslateName>

I think for inline blocks, it would be helpful if we supported an alternative syntax:

<LuaHookTranslateName>
if r.uri == "/translate-name" then
   r.uri = "/find_me.txt"
   return apache2.DECLINED
end
return apache2.DECLINED
</LuaHookTranslateName>

Basically, when the function parameter is missing ('my_function_to_call' in the first block) from the LuaHookTranslateName section header, we should switch into a mode which:
 - Automagically pushes in apache2.
 - Automagically pushes in r

This would make it much easier to read than forcing simple inline scripts to always use a function....

I think it can be done in wombat_request_rec_hook_harness, if hook_spec->function_name is NULL, then assume that we need to set these globals -- and then apw_run_wombat_request should be able to continue as normal.

Thoughts?

Thanks,

Paul

Reply via email to