Mod Wombat |
|
以下是关于 mod_wombat 可以/应该进行的改进的一些想法。这些想法来自 Brian Akins。
// Ability for other modules to call lua without worrying about caching, // compiling, etc. i.e. something like: APR_DECLARE_OPTIONAL_FN(apr_status_t, lua_request_register, (apr_pool_t *pool, lua_request_t **new, const char *file)); APR_DECLARE_OPTIONAL_FN(apr_status_t, lua_request_run, (request_rec * r, lua_request_t *run, const char *function, apr_status_t *rc));
理论上,这个通用的“框架”将由 mod_wombat 在内部使用。
- 每个线程一个虚拟机。一个 httpd 线程为每个文件分配一个专用的 Lua 虚拟机。
(我们做了这两件事^^。Brian M. 拥有我们非常修改过的 mod_wombat 版本。如果有兴趣,我可以将其发布在这里)
支持在 httpd.conf 中使用 Lua。也就是说,我希望能够直接在配置文件中编写“简单的”Lua 代码,而不是必须使用单独的文件。
<Lua my_cool_code>
require 'string'
require 'apache2'
function simple_redirect(r)
if string.match(r.headers_in['User-Agent'], 'mozilla') then
r.headers_out['Location'] = 'http://somecoolmozillasite.com/stuff'
return apache2.HTTP_MOVED_TEMPORARILY
end
end
</Lua>
<Location /my_ie_only_app>
LuaHook fixups my_cool_code:simple_redirect
</Location>
(这是一个不恰当的例子,但您能理解大致意思)
使用 Lua 创建“真实”模块的能力
function register_hooks(p) apache2.hook_handler(my_handler, NULL, NULL, apache2.HOOK_MIDDLE) end apache2.module( apache2.STANDARD20_MODULE_STUFF, create_dir_cfg, merge_dir_cfg, create_svr_cfg, merge_svr_cfg, cmd_table, register_hooks )
我认为模块加载是这个地方可能比较棘手的地方。
对于真正雄心勃勃的人来说,我希望能够通过 Lua 配置 Apache
httpd.load_module('mime_module', 'modules/mod_mime.so') v = apache2.server.new() v:document_root = '/opt/apache/htdocs' mod_mime:types_config = '/etc/mime.types' mod_env.set_env('X-Lua', 'is cool')
这不是有效代码,但大概是这样的...