You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Querna <ch...@force-elite.com> on 2008/11/08 09:16:36 UTC
[wombat] supporting functionless blocks
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
Re: [wombat] supporting functionless blocks
Posted by Brian McCallister <br...@skife.org>.
On Sun, Nov 9, 2008 at 11:04 AM, Paul Querna <ch...@force-elite.com> wrote:
> I think Brian was planning taking a bigger hacksaw in though with
> refactoring the VM allocation, so i kinda want to wait until that is done
> before trying to clean some of this up.
Am indeed intending to go at lua_State creation and management with a
hacksaw. Lifecycle management should be tied to pools, not ad-hoc
structures attached to server_rc, conn_rec, or request_rec. The most
primitive part (create a lua_state attached to a pool, only apr
dependent) is there, but good idioms or convenience functions are
lacking, and most of the code doesn't use the new form, yet.
-Brian
Re: [wombat] supporting functionless blocks
Posted by Paul Querna <ch...@force-elite.com>.
Justin Erenkrantz wrote:
> On Sat, Nov 8, 2008 at 2:16 AM, Paul Querna <ch...@force-elite.com> wrote:
>> 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?
>
> Seems reasonable to me. -- justin
So, I've done it:
<LuaHookTranslateName foo>
function foo(r)
if r.uri == "/translate-name" then
r.uri = "/find_me.txt"
return apache2.OK
end
return apache2.DECLINED
end
</LuaHookTranslateName>
<LuaHookTranslateName>
if r.uri == "/translate-name" then
r.uri = "/find_me.txt"
return apache2.OK
end
return apache2.DECLINED
</LuaHookTranslateName>
Both now do the same thing in mod_wombat trunk :-)
Though the code is getting ugly.. and thats my fault.
I think Brian was planning taking a bigger hacksaw in though with
refactoring the VM allocation, so i kinda want to wait until that is
done before trying to clean some of this up.
Thanks,
Paul
Re: [wombat] supporting functionless blocks
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On Sat, Nov 8, 2008 at 2:16 AM, Paul Querna <ch...@force-elite.com> wrote:
> 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?
Seems reasonable to me. -- justin