mod_lua.xml revision b60ba9fb00026d3dbca744c6c19afe63cba3a3d1
d5b7ba26785d7494166d48876362ba30ff30b98awrowe<?xml version="1.0"?>
c30ef289fe64ac7fedc44cfcc6b439f0f8458b4cgregames<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
c30ef289fe64ac7fedc44cfcc6b439f0f8458b4cgregames<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5541a81e194dc99521c0ecf904a940b0b65a93f2nd<!-- $LastChangedRevision$ -->
8eeb24cab1b849bd17726d0a030cd299209f108cnd
8eeb24cab1b849bd17726d0a030cd299209f108cnd<!--
8eeb24cab1b849bd17726d0a030cd299209f108cnd Licensed to the Apache Software Foundation (ASF) under one or more
8eeb24cab1b849bd17726d0a030cd299209f108cnd contributor license agreements. See the NOTICE file distributed with
8eeb24cab1b849bd17726d0a030cd299209f108cnd this work for additional information regarding copyright ownership.
c2d16e88f6a997b9174b5596db5e03cee5f46a8brederpj The ASF licenses this file to You under the Apache License, Version 2.0
c2d16e88f6a997b9174b5596db5e03cee5f46a8brederpj (the "License"); you may not use this file except in compliance with
7edcfe02796a70f2a5eac12b6766d11067c629a3rederpj the License. You may obtain a copy of the License at
c2d16e88f6a997b9174b5596db5e03cee5f46a8brederpj
c2d16e88f6a997b9174b5596db5e03cee5f46a8brederpj http://www.apache.org/licenses/LICENSE-2.0
c2d16e88f6a997b9174b5596db5e03cee5f46a8brederpj
a4dd3688dd6645faf0c1c1bfb22017c8f03d5b24nd Unless required by applicable law or agreed to in writing, software
a4dd3688dd6645faf0c1c1bfb22017c8f03d5b24nd distributed under the License is distributed on an "AS IS" BASIS,
a4dd3688dd6645faf0c1c1bfb22017c8f03d5b24nd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a16ca336064074171bffc3a6da3444243a06b62btrawick See the License for the specific language governing permissions and
a16ca336064074171bffc3a6da3444243a06b62btrawick limitations under the License.
a16ca336064074171bffc3a6da3444243a06b62btrawick-->
f2fe083bb9fabd2af7eb39d4f154f27a451bb5a4nd
f2fe083bb9fabd2af7eb39d4f154f27a451bb5a4nd<modulesynopsis metafile="mod_lua.xml.meta">
f2fe083bb9fabd2af7eb39d4f154f27a451bb5a4nd
f2fe083bb9fabd2af7eb39d4f154f27a451bb5a4nd<name>mod_lua</name>
7de6cb79f71a9007ba2b1e786cbad8b84f05d101nd
7de6cb79f71a9007ba2b1e786cbad8b84f05d101nd<description>Provides Lua hooks into various portions of the httpd
7de6cb79f71a9007ba2b1e786cbad8b84f05d101ndrequest processing</description>
7de6cb79f71a9007ba2b1e786cbad8b84f05d101nd<status>Experimental</status>
862562bece2467ae2e729a270279e07522c654a9rederpj<sourcefile>mod_lua.c</sourcefile>
862562bece2467ae2e729a270279e07522c654a9rederpj<identifier>lua_module</identifier>
862562bece2467ae2e729a270279e07522c654a9rederpj<compatibility>2.3 and later</compatibility>
862562bece2467ae2e729a270279e07522c654a9rederpj
862562bece2467ae2e729a270279e07522c654a9rederpj<summary>
862562bece2467ae2e729a270279e07522c654a9rederpj<p>This module allows the server to be extended with scripts written in the
862562bece2467ae2e729a270279e07522c654a9rederpjLua programming language. The extension points (hooks) available with
aa9b03a5f32732c0caaef03a7ed78ffb290e29e4trawick<module>mod_lua</module> include many of the hooks available to
aa9b03a5f32732c0caaef03a7ed78ffb290e29e4trawicknatively compiled Apache HTTP Server modules, such as mapping requests to
aa9b03a5f32732c0caaef03a7ed78ffb290e29e4trawickfiles, generating dynamic responses, access control, authentication, and
a81c9e8561ebd18177a87fecf1226ac654b873f1rederpjauthorization</p>
a81c9e8561ebd18177a87fecf1226ac654b873f1rederpj
a81c9e8561ebd18177a87fecf1226ac654b873f1rederpj<p>More information on the Lua programming language can be found at the
a81c9e8561ebd18177a87fecf1226ac654b873f1rederpj<a href="http://www.lua.org/">the Lua website</a>.</p>
d1c46782edbd6bd5ae4592c0174969950c5ca8aetrawick
d1c46782edbd6bd5ae4592c0174969950c5ca8aetrawick<note><code>mod_lua</code> is still in experimental state.
d1c46782edbd6bd5ae4592c0174969950c5ca8aetrawickUntil it is declared stable, usage and behavior may change
a3954060338ccebc73071e89ac936d4ec15ab352trawickat any time.</note>
a3954060338ccebc73071e89ac936d4ec15ab352trawick
a3954060338ccebc73071e89ac936d4ec15ab352trawick</summary>
a3954060338ccebc73071e89ac936d4ec15ab352trawick
ab56518227d474ee08f039e4c5540011c1b8a913trawick<section id="basicconf"><title>Basic Configuration</title>
ab56518227d474ee08f039e4c5540011c1b8a913trawick
ab56518227d474ee08f039e4c5540011c1b8a913trawick<p>The basic module loading directive is</p>
4e330708371c3e9b04d1043f0a1ac9368bfbd768coar
4e330708371c3e9b04d1043f0a1ac9368bfbd768coar<example>
4e330708371c3e9b04d1043f0a1ac9368bfbd768coar LoadModule lua_module modules/mod_lua.so
532a5de31e1a9732da4923f88e4931d0724ebe72nd</example>
532a5de31e1a9732da4923f88e4931d0724ebe72nd
532a5de31e1a9732da4923f88e4931d0724ebe72nd<p>
219e31b849ef108cd8f58ba0eedae03414e5edb1thommay<code>mod_lua</code> provides a handler named <code>lua-script</code>,
a98959721afc481c7f3a941f85c462f0b90defdathommaywhich can be used with an <code>AddHandler</code> directive:</p>
a98959721afc481c7f3a941f85c462f0b90defdathommay
a98959721afc481c7f3a941f85c462f0b90defdathommay<example>
219e31b849ef108cd8f58ba0eedae03414e5edb1thommayAddHandler lua-script .lua
dbb916b882c33a4e340b0dba7d75506cfdd85640trawick</example>
dbb916b882c33a4e340b0dba7d75506cfdd85640trawick
dbb916b882c33a4e340b0dba7d75506cfdd85640trawick<p>
dbb916b882c33a4e340b0dba7d75506cfdd85640trawickThis will cause <code>mod_lua</code> to handle requests for files
dbb916b882c33a4e340b0dba7d75506cfdd85640trawickending in <code>.lua</code> by invoking that file's
a18a308d7a942230edcde1bf00d7ae9b4b143c90trawick<code>handle</code> function.
a18a308d7a942230edcde1bf00d7ae9b4b143c90trawick</p>
a18a308d7a942230edcde1bf00d7ae9b4b143c90trawick
9efe68be3c81ee85225972195fb725dbfc2e8b24trawick<p>For more flexibility, see <directive>LuaMapHandler</directive>.
9098f795fab5db41a52b6b82fa475e8f9b3850f0trawick</p>
9098f795fab5db41a52b6b82fa475e8f9b3850f0trawick
9098f795fab5db41a52b6b82fa475e8f9b3850f0trawick</section>
9efe68be3c81ee85225972195fb725dbfc2e8b24trawick
3b872593fd5f61981d9dd69a4b0b5d5f5f668929trawick<section id="writinghandlers"><title>Writing Handlers</title>
3b872593fd5f61981d9dd69a4b0b5d5f5f668929trawick<p> In the Apache HTTP Server API, the handler is a specific kind of hook
3b872593fd5f61981d9dd69a4b0b5d5f5f668929trawickresponsible for generating the response. Examples of modules that include a
fc25339741311efd7d460f18b6287ef38d76bbe6madhumhandler are <module>mod_proxy</module>, <module>mod_cgi</module>,
fc25339741311efd7d460f18b6287ef38d76bbe6madhumand <module>mod_status</module>.</p>
fc25339741311efd7d460f18b6287ef38d76bbe6madhum
fc25339741311efd7d460f18b6287ef38d76bbe6madhum<p><code>mod_lua</code> always looks to invoke a Lua function for the handler, rather than
fcdca175a52fe517f2317ba0e2b6e6d14522b869madhumjust evaluating a script body CGI style. A handler function looks
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantzsomething like this:</p>
92a2439559cf1161742650ed9c50c6483bd029cemadhum
92a2439559cf1161742650ed9c50c6483bd029cemadhum<example><title>example.lua</title><pre>
92a2439559cf1161742650ed9c50c6483bd029cemadhum-- example handler
92a2439559cf1161742650ed9c50c6483bd029cemadhum
ebecc16986604cce1369d5075eff65032e3dd0deianhrequire "string"
0d60370bedd05f9632f54e85c417ce472d463674madhum
ebecc16986604cce1369d5075eff65032e3dd0deianh--[[
764315969cef40e50cdc6a5e9638454e10c1c06end This is the default method name for Lua handlers, see the optional
764315969cef40e50cdc6a5e9638454e10c1c06end function-name in the LuaMapHandler directive to choose a different
764315969cef40e50cdc6a5e9638454e10c1c06end entry point.
764315969cef40e50cdc6a5e9638454e10c1c06end--]]
bfb54bd96690887dcdf184fd9083c2e167898ce2ndfunction handle(r)
a2c036f0ca71e35c085b4cd9451a6d3718bc65daake r.content_type = "text/plain"
a2c036f0ca71e35c085b4cd9451a6d3718bc65daake r:puts("Hello Lua World!\n")
a2c036f0ca71e35c085b4cd9451a6d3718bc65daake
a2c036f0ca71e35c085b4cd9451a6d3718bc65daake if r.method == 'GET' then
b92cba59a0890be43b14aaf1ce30606140be9593nd for k, v in pairs( r:parseargs() ) do
b92cba59a0890be43b14aaf1ce30606140be9593nd r:puts( string.format("%s: %s", k, v) )
b92cba59a0890be43b14aaf1ce30606140be9593nd end
b92cba59a0890be43b14aaf1ce30606140be9593nd elseif r.method == 'POST' then
402d23baca89e8c4fcb4e52ad8b2d66a6904baaetrawick for k, v in pairs( r:parsebody() ) do
402d23baca89e8c4fcb4e52ad8b2d66a6904baaetrawick r:puts( string.format("%s: %s", k, v) )
402d23baca89e8c4fcb4e52ad8b2d66a6904baaetrawick end
4caa28863a3418d26cc20a998dc368c3de3b7e19jerenkrantz else
4caa28863a3418d26cc20a998dc368c3de3b7e19jerenkrantz r:puts("unknown HTTP method " .. r.method)
4caa28863a3418d26cc20a998dc368c3de3b7e19jerenkrantz end
a3f2646ef3d8a3a5234a5601de0f95f10308c2a6jerenkrantzend
a3f2646ef3d8a3a5234a5601de0f95f10308c2a6jerenkrantz</pre></example>
a3f2646ef3d8a3a5234a5601de0f95f10308c2a6jerenkrantz
9e398d701dd430f073ff5418fb720642e064046ajerenkrantz<p>
9e398d701dd430f073ff5418fb720642e064046ajerenkrantzThis handler function just prints out the uri or form encoded
9e398d701dd430f073ff5418fb720642e064046ajerenkrantzarguments to a plaintext page.
1a5b9e0071f0c662036250b482d566ad87ff0b4bjerenkrantz</p>
1a5b9e0071f0c662036250b482d566ad87ff0b4bjerenkrantz
1a5b9e0071f0c662036250b482d566ad87ff0b4bjerenkrantz<p>
a7ac9b52c3d9f7ce937f078a0d585023db626c55jerenkrantzThis means (and in fact encourages) that you can have multiple
a7ac9b52c3d9f7ce937f078a0d585023db626c55jerenkrantzhandlers (or hooks, or filters) in the same script.
a7ac9b52c3d9f7ce937f078a0d585023db626c55jerenkrantz</p>
ba6c07204bd224fa5d4cd0e6b8bf256d6daffb74nd
ba6c07204bd224fa5d4cd0e6b8bf256d6daffb74nd</section>
ba6c07204bd224fa5d4cd0e6b8bf256d6daffb74nd
db5837bbc9bef214303e755fa52122140366cb6fianh<section id="writinghooks"><title>Writing Hooks</title>
db5837bbc9bef214303e755fa52122140366cb6fianh
db5837bbc9bef214303e755fa52122140366cb6fianh<p>Hook functions are how modules (and Lua scripts) participate in the
aac2b82fe4f1ac117e2a0702438d6615542642dandprocessing of requests. Each type of hook exposed by the server exists for
aac2b82fe4f1ac117e2a0702438d6615542642danda specific purposes such as mapping requests to the filesystem,
aac2b82fe4f1ac117e2a0702438d6615542642dandperforming access control, or setting mimetypes. General purpose hooks
a793d402c74e50326a2401cfbdc562c5781948fdndthat simply run at handy times in the request lifecycle exist as well.</p>
a793d402c74e50326a2401cfbdc562c5781948fdnd
0a209fcb17b8c9a42a6149a1758e61cf6527d367nd<p>Hook functions are passed the request object as their only argument.
a793d402c74e50326a2401cfbdc562c5781948fdndThey can return any value, depending on the hook, but most commonly
99d360dcbb5ac2be27694be74cc6124dbadf3315jerenkrantzthey'll return OK, DONE, or DECLINED, which you can write in lua as
99d360dcbb5ac2be27694be74cc6124dbadf3315jerenkrantz<code>apache2.OK</code>, <code>apache2.DONE</code>, or
99d360dcbb5ac2be27694be74cc6124dbadf3315jerenkrantz<code>apache2.DECLINED</code>, or else an HTTP status code.</p>
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz<example><title>translate_name.lua</title><pre>
3ded62d7f2c9b12616d718b8c97d3044baa9ecdbjerenkrantz-- example hook that rewrites the URI to a filesystem path.
ab8c0315521735c73ce16c8072f91e17c406ca5bnd
ab8c0315521735c73ce16c8072f91e17c406ca5bndrequire 'apache2'
ab8c0315521735c73ce16c8072f91e17c406ca5bnd
b9e99e0d3154bbebe3e1b8d11d6c15bde79510a5ndfunction translate_name(r)
b9e99e0d3154bbebe3e1b8d11d6c15bde79510a5nd if r.uri == "/translate-name" then
b9e99e0d3154bbebe3e1b8d11d6c15bde79510a5nd r.filename = r.document_root .. "/find_me.txt"
b9e99e0d3154bbebe3e1b8d11d6c15bde79510a5nd return apache2.OK
ea5f8cfbb7ef1d19318f6994c26dd73c38ffd8ddjerenkrantz end
ea5f8cfbb7ef1d19318f6994c26dd73c38ffd8ddjerenkrantz -- we don't care about this URL, give another module a chance
ea5f8cfbb7ef1d19318f6994c26dd73c38ffd8ddjerenkrantz return apache2.DECLINED
4567cfc6a65328bd3e8dd2b758ca926b389c7058brianpend
4567cfc6a65328bd3e8dd2b758ca926b389c7058brianp</pre></example>
4567cfc6a65328bd3e8dd2b758ca926b389c7058brianp
4cdc5446050c19b9d519a273a129188586e8d445jerenkrantz<example><title>translate_name2.lua</title><pre>
4cdc5446050c19b9d519a273a129188586e8d445jerenkrantz--[[ example hook that rewrites one URI to another URI. It returns a
4cdc5446050c19b9d519a273a129188586e8d445jerenkrantz apache2.DECLINED to give other URL mappers a chance to work on the
2f408250e9111c4b85b2b4b9b8836e83987efdefstoddard substitution, including the core translate_name hook which maps based
2f408250e9111c4b85b2b4b9b8836e83987efdefstoddard on the DocumentRoot.
2f408250e9111c4b85b2b4b9b8836e83987efdefstoddard
2f408250e9111c4b85b2b4b9b8836e83987efdefstoddard Note: It is currently undefined as to whether this runs before or after
d5b7ba26785d7494166d48876362ba30ff30b98awrowe mod_alias.
47fe07199bddec6124ab7251c6be5c6c9ac00485jerenkrantz--]]
47fe07199bddec6124ab7251c6be5c6c9ac00485jerenkrantz
6646a289c2d4778c8cd43d62b5a1cc966a356f85jerenkrantzrequire 'apache2'
6646a289c2d4778c8cd43d62b5a1cc966a356f85jerenkrantz
6646a289c2d4778c8cd43d62b5a1cc966a356f85jerenkrantzfunction translate_name(r)
6646a289c2d4778c8cd43d62b5a1cc966a356f85jerenkrantz if r.uri == "/translate-name" then
aec70520ebe1e33e0d5e83c3626649d2a41dbe68wrowe r.uri = "/find_me.txt"
aec70520ebe1e33e0d5e83c3626649d2a41dbe68wrowe return apache2.DECLINED
aec70520ebe1e33e0d5e83c3626649d2a41dbe68wrowe end
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe return apache2.DECLINED
ad451e2e428a069086d1c18c9e3372f8846ec617wroweend
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe</pre></example>
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe</section>
59b910556d04c82e951d6c6f7a413ab8fed21467trawick
59b910556d04c82e951d6c6f7a413ab8fed21467trawick<section id="datastructures"><title>Data Structures</title>
cde00ab9085ea6e93db4a27bf6fe9a9b6eda4addnd
cde00ab9085ea6e93db4a27bf6fe9a9b6eda4addnd<dl>
cde00ab9085ea6e93db4a27bf6fe9a9b6eda4addnd<dt>request_rec</dt>
cde00ab9085ea6e93db4a27bf6fe9a9b6eda4addnd <dd>
cde00ab9085ea6e93db4a27bf6fe9a9b6eda4addnd <p>The request_rec is mapped in as a userdata. It has a metatable
cde00ab9085ea6e93db4a27bf6fe9a9b6eda4addnd which lets you do useful things with it. For the most part it
159d95df05b3100bbef7a60cb5f5d7d8d5a3328etrawick has the same fields as the request_rec struct (see httpd.h
159d95df05b3100bbef7a60cb5f5d7d8d5a3328etrawick until we get better docs here) many of which are writeable as
159d95df05b3100bbef7a60cb5f5d7d8d5a3328etrawick well as readable. (The table fields' content can be changed, but the
159d95df05b3100bbef7a60cb5f5d7d8d5a3328etrawick fields themselves cannot be set to different tables.)</p>
59b910556d04c82e951d6c6f7a413ab8fed21467trawick
59b910556d04c82e951d6c6f7a413ab8fed21467trawick <table border="1">
59b910556d04c82e951d6c6f7a413ab8fed21467trawick
59b910556d04c82e951d6c6f7a413ab8fed21467trawick <tr>
59b910556d04c82e951d6c6f7a413ab8fed21467trawick <th><strong>Name</strong></th>
9768955299008e29705461b314b763a79104e576nd <th><strong>Lua type</strong></th>
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd <th><strong>Writable</strong></th>
03e310ef946842b4dfa718776c870d012fc9ec67striker </tr>
03e310ef946842b4dfa718776c870d012fc9ec67striker <tr>
03e310ef946842b4dfa718776c870d012fc9ec67striker <td><code>ap_auth_type</code></td>
03e310ef946842b4dfa718776c870d012fc9ec67striker <td>string</td>
03e310ef946842b4dfa718776c870d012fc9ec67striker <td>no</td>
03e310ef946842b4dfa718776c870d012fc9ec67striker </tr>
611d2f4e86b4eceb640a5301bd88a23cb459e5a8striker <tr>
611d2f4e86b4eceb640a5301bd88a23cb459e5a8striker <td><code>args</code></td>
611d2f4e86b4eceb640a5301bd88a23cb459e5a8striker <td>string</td>
611d2f4e86b4eceb640a5301bd88a23cb459e5a8striker <td>no</td>
611d2f4e86b4eceb640a5301bd88a23cb459e5a8striker </tr>
f59888906d0566361498848fa95b4c416fad976cstriker <tr>
f59888906d0566361498848fa95b4c416fad976cstriker <td><code>assbackwards</code></td>
f59888906d0566361498848fa95b4c416fad976cstriker <td>boolean</td>
f59888906d0566361498848fa95b4c416fad976cstriker <td>no</td>
f59888906d0566361498848fa95b4c416fad976cstriker </tr>
6a3078c438bee65f22004ac65cd2eb4fa521bbfastriker
6a3078c438bee65f22004ac65cd2eb4fa521bbfastriker <tr>
6a3078c438bee65f22004ac65cd2eb4fa521bbfastriker <td><code>canonical_filename</code></td>
6a3078c438bee65f22004ac65cd2eb4fa521bbfastriker <td>string</td>
26acc990e97a62631a3654405d676b928a78ebbcstriker <td>no</td>
26acc990e97a62631a3654405d676b928a78ebbcstriker </tr>
29ecc0949b383793b24cdd0741cb86c02138ab36striker <tr>
29ecc0949b383793b24cdd0741cb86c02138ab36striker <td><code>content_encoding</code></td>
29ecc0949b383793b24cdd0741cb86c02138ab36striker <td>string</td>
29ecc0949b383793b24cdd0741cb86c02138ab36striker <td>no</td>
29ecc0949b383793b24cdd0741cb86c02138ab36striker </tr>
29ecc0949b383793b24cdd0741cb86c02138ab36striker <tr>
c97f8ff3a7479c838545de0c59770938b50ab6d3gstein <td><code>content_type</code></td>
c97f8ff3a7479c838545de0c59770938b50ab6d3gstein <td>string</td>
c97f8ff3a7479c838545de0c59770938b50ab6d3gstein <td>yes</td>
6fb9d10c529c2be3bb1833b0eefdd27ba4df1610trawick </tr>
6fb9d10c529c2be3bb1833b0eefdd27ba4df1610trawick
6fb9d10c529c2be3bb1833b0eefdd27ba4df1610trawick <tr>
6fb9d10c529c2be3bb1833b0eefdd27ba4df1610trawick <td><code>document_root</code></td>
6fb9d10c529c2be3bb1833b0eefdd27ba4df1610trawick <td>string</td>
6fb9d10c529c2be3bb1833b0eefdd27ba4df1610trawick <td>no</td>
368a950bc36b428b737d079f77e8962c831f88aand </tr>
368a950bc36b428b737d079f77e8962c831f88aand <tr>
368a950bc36b428b737d079f77e8962c831f88aand <td><code>err_headers_out</code></td>
368a950bc36b428b737d079f77e8962c831f88aand <td>table</td>
9768955299008e29705461b314b763a79104e576nd <td>no</td>
1ead2314e821e9ac264ea35425e7d0816030e404stoddard </tr>
9768955299008e29705461b314b763a79104e576nd <tr>
9768955299008e29705461b314b763a79104e576nd <td><code>filename</code></td>
9768955299008e29705461b314b763a79104e576nd <td>string</td>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <td>yes</td>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc </tr>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <tr>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <td><code>headers_in</code></td>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <td>table</td>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <td>yes</td>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc </tr>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <tr>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <td><code>headers_out</code></td>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <td>table</td>
1005ad40d72c4a1df2c0f1b95b770a4c43c49a47mjc <td>yes</td>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz </tr>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <tr>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <td><code>hostname</code></td>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <td>string</td>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <td>no</td>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz </tr>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <tr>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <td><code>method</code></td>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <td>string</td>
da5a84048552168ea64c3012573acd4de1434dcdjerenkrantz <td>no</td>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz </tr>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz <tr>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz <td><code>notes</code></td>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz <td>table</td>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz <td>yes</td>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz </tr>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz <tr>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz <td><code>path_info</code></td>
19fdbc5566bf67dde644be9e8d38d62db4dd0ba5jerenkrantz <td>string</td>
e874834efe9943668668c7fa498af3b3c7caffbdnd <td>no</td>
e874834efe9943668668c7fa498af3b3c7caffbdnd </tr>
e874834efe9943668668c7fa498af3b3c7caffbdnd <tr>
e874834efe9943668668c7fa498af3b3c7caffbdnd <td><code>protocol</code></td>
e874834efe9943668668c7fa498af3b3c7caffbdnd <td>string</td>
e874834efe9943668668c7fa498af3b3c7caffbdnd <td>no</td>
e874834efe9943668668c7fa498af3b3c7caffbdnd </tr>
b617020883fa3b18bc9b5be5e896ceed79a7ff7fnd <tr>
b617020883fa3b18bc9b5be5e896ceed79a7ff7fnd <td><code>range</code></td>
b617020883fa3b18bc9b5be5e896ceed79a7ff7fnd <td>string</td>
38873f61704cbe5eadaa3fb9dca84a4bee1ae5d5wrowe <td>no</td>
38873f61704cbe5eadaa3fb9dca84a4bee1ae5d5wrowe </tr>
38873f61704cbe5eadaa3fb9dca84a4bee1ae5d5wrowe <tr>
38873f61704cbe5eadaa3fb9dca84a4bee1ae5d5wrowe <td><code>status</code></td>
38873f61704cbe5eadaa3fb9dca84a4bee1ae5d5wrowe <td>number</td>
68a80326bd8b6f717ae0c44d4bb7273023aad1edwrowe <td>yes</td>
68a80326bd8b6f717ae0c44d4bb7273023aad1edwrowe </tr>
68a80326bd8b6f717ae0c44d4bb7273023aad1edwrowe <tr>
68a80326bd8b6f717ae0c44d4bb7273023aad1edwrowe <td><code>the_request</code></td>
68a80326bd8b6f717ae0c44d4bb7273023aad1edwrowe <td>string</td>
68a80326bd8b6f717ae0c44d4bb7273023aad1edwrowe <td>no</td>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe </tr>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe <tr>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe <td><code>unparsed_uri</code></td>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe <td>string</td>
903c124068c87c957f1327de486017a19cccd348stoddard <td>no</td>
903c124068c87c957f1327de486017a19cccd348stoddard </tr>
903c124068c87c957f1327de486017a19cccd348stoddard <tr>
903c124068c87c957f1327de486017a19cccd348stoddard <td><code>uri</code></td>
732269e2780cb818c1b48aeffa0b432b0ce4ee5eaaron <td>string</td>
732269e2780cb818c1b48aeffa0b432b0ce4ee5eaaron <td>yes</td>
20aa030accab9a4df293294283fbe6a4ae961588trawick </tr>
20aa030accab9a4df293294283fbe6a4ae961588trawick <tr>
20aa030accab9a4df293294283fbe6a4ae961588trawick <td><code>user</code></td>
b617020883fa3b18bc9b5be5e896ceed79a7ff7fnd <td>string</td>
e08b3783b570fdea39520da5e6c174394e956d17nd <td>yes</td>
e08b3783b570fdea39520da5e6c174394e956d17nd </tr>
e08b3783b570fdea39520da5e6c174394e956d17nd </table>
e08b3783b570fdea39520da5e6c174394e956d17nd
e08b3783b570fdea39520da5e6c174394e956d17nd <p>The request_rec has (at least) the following methods:</p>
e08b3783b570fdea39520da5e6c174394e956d17nd
e08b3783b570fdea39520da5e6c174394e956d17nd <example>
e08b3783b570fdea39520da5e6c174394e956d17nd r:addoutputfilter(name|function) -- add an output filter
e08b3783b570fdea39520da5e6c174394e956d17nd </example>
e08b3783b570fdea39520da5e6c174394e956d17nd
16de8ff78c533f06c64d5ab2b685953992ff8659thommay <example>
16de8ff78c533f06c64d5ab2b685953992ff8659thommay r:parseargs() -- returns a lua table containing the request's
16de8ff78c533f06c64d5ab2b685953992ff8659thommay query string arguments
16de8ff78c533f06c64d5ab2b685953992ff8659thommay </example>
5aef954598e763eea457d204897a6a12d281755dtrawick
5aef954598e763eea457d204897a6a12d281755dtrawick <example>
5aef954598e763eea457d204897a6a12d281755dtrawick r:parsebody() -- parse the request body as a POST and return
5aef954598e763eea457d204897a6a12d281755dtrawick a lua table
340e970018246649e86dd3ebbd34f4719e3ceaf7trawick </example>
340e970018246649e86dd3ebbd34f4719e3ceaf7trawick
340e970018246649e86dd3ebbd34f4719e3ceaf7trawick <example>
340e970018246649e86dd3ebbd34f4719e3ceaf7trawick r:puts("hello", " world", "!") -- print to response body
1360e9b0036040edfbcd2273ae18db83a93536detrawick </example>
1360e9b0036040edfbcd2273ae18db83a93536detrawick
1360e9b0036040edfbcd2273ae18db83a93536detrawick <example>
1360e9b0036040edfbcd2273ae18db83a93536detrawick r:write("a single string") -- print to response body
1360e9b0036040edfbcd2273ae18db83a93536detrawick </example>
1360e9b0036040edfbcd2273ae18db83a93536detrawick </dd>
c3f32ea297c5350948a0c4472c1ff8433ea4e6bastoddard </dl>
c3f32ea297c5350948a0c4472c1ff8433ea4e6bastoddard
c3f32ea297c5350948a0c4472c1ff8433ea4e6bastoddard</section>
c3f32ea297c5350948a0c4472c1ff8433ea4e6bastoddard
6838d0e05a193cb77265db36e3549201b3df57e6wrowe<section id="logging"><title>Logging Functions</title>
c3f32ea297c5350948a0c4472c1ff8433ea4e6bastoddard
946f7bd76a0dec6d67af79af56a8cff3cb6ef9c1nd<example>
946f7bd76a0dec6d67af79af56a8cff3cb6ef9c1nd -- examples of logging messages<br />
946f7bd76a0dec6d67af79af56a8cff3cb6ef9c1nd r:trace1("This is a trace log message") -- trace1 through trace8 can be used <br />
946f7bd76a0dec6d67af79af56a8cff3cb6ef9c1nd r:debug("This is a debug log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd r:info("This is an info log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd r:notice("This is an notice log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd r:warn("This is an warn log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd r:err("This is an err log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd r:alert("This is an alert log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd r:crit("This is an crit log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd r:emerg("This is an emerg log message")<br />
8c038cdb417502a969599568ccc4020576d82a10nd</example>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe
6838d0e05a193cb77265db36e3549201b3df57e6wrowe</section>
83938932cb2dbe320eda488799bb7a0c04156bcdake
83938932cb2dbe320eda488799bb7a0c04156bcdake<section id="apache2"><title>apache2 Package</title>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe<p>A package named <code>apache2</code> is available with (at least) the following contents.</p>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe<dl>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe <dt>apache2.OK</dt>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe <dd>internal constant OK. Handlers should return this if they've
6838d0e05a193cb77265db36e3549201b3df57e6wrowe handled the request.</dd>
6fbf645df300ffa9c9693399571f2cd821af06fdtrawick <dt>apache2.DECLINED</dt>
6fbf645df300ffa9c9693399571f2cd821af06fdtrawick <dd>internal constant DECLINED. Handlers should return this if
6fbf645df300ffa9c9693399571f2cd821af06fdtrawick they are not going to handle the request.</dd>
6fbf645df300ffa9c9693399571f2cd821af06fdtrawick <dt>apache2.DONE</dt>
6fbf645df300ffa9c9693399571f2cd821af06fdtrawick <dd>internal constant DONE.</dd>
c8ff8621370eb28a3f697a00bf5e6b3bc1a0d9f1minfrin <dt>apache2.version</dt>
c8ff8621370eb28a3f697a00bf5e6b3bc1a0d9f1minfrin <dd>Apache HTTP server version string</dd>
c8ff8621370eb28a3f697a00bf5e6b3bc1a0d9f1minfrin <dt>apache2.HTTP_MOVED_TEMPORARILY</dt>
c8ff8621370eb28a3f697a00bf5e6b3bc1a0d9f1minfrin <dd>HTTP status code</dd>
c8ff8621370eb28a3f697a00bf5e6b3bc1a0d9f1minfrin</dl>
c8989f842c2ad4533950c13d99d3dfb099da0d67minfrin<p>(Other HTTP status codes are not yet implemented.)</p>
c8989f842c2ad4533950c13d99d3dfb099da0d67minfrin</section>
c8989f842c2ad4533950c13d99d3dfb099da0d67minfrin
c8989f842c2ad4533950c13d99d3dfb099da0d67minfrin<directivesynopsis>
97610ac677a5eda4a3bb366c5bb34a27eeb4288cminfrin<name>LuaRoot</name>
97610ac677a5eda4a3bb366c5bb34a27eeb4288cminfrin<description>Specify the base path for resolving relative paths for mod_lua directives</description>
97610ac677a5eda4a3bb366c5bb34a27eeb4288cminfrin<syntax>LuaRoot /path/to/a/directory</syntax>
6aa783d83f4304f664233d8252cb67116769676ewrowe<contextlist><context>server config</context><context>virtual host</context>
6aa783d83f4304f664233d8252cb67116769676ewrowe<context>directory</context><context>.htaccess</context>
6aa783d83f4304f664233d8252cb67116769676ewrowe</contextlist>
6aa783d83f4304f664233d8252cb67116769676ewrowe<override>All</override>
6aa783d83f4304f664233d8252cb67116769676ewrowe
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd<usage>
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd <p>Specify the base path which will be used to evaluate all
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd relative paths within mod_lua. If not specified they
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd will be resolved relative to the current working directory,
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd which may not always work well for a server.</p>
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd</usage>
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd</directivesynopsis>
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd<directivesynopsis>
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd<name>LuaScope</name>
761fb8d21084bd7b7eb590fbd54a925dfdf806bbnd<description>One of once, request, conn, server -- default is once</description>
367cefc17f8dcfe65651c9c16cb3151589c6cecetrawick<syntax>LuaScope once|request|conn|server [max|min max]</syntax>
5d6ffa7b5c77dd4132ed6d7f0dd63548b1c3c1c9nd<default>LuaScope once</default>
d8f54fe5534b61afa68100dddbe2eb98285d1100wrowe<contextlist><context>server config</context><context>virtual host</context>
d8f54fe5534b61afa68100dddbe2eb98285d1100wrowe<context>directory</context><context>.htaccess</context>
d8f54fe5534b61afa68100dddbe2eb98285d1100wrowe</contextlist>
d8f54fe5534b61afa68100dddbe2eb98285d1100wrowe<override>All</override>
d8f54fe5534b61afa68100dddbe2eb98285d1100wrowe
6aa783d83f4304f664233d8252cb67116769676ewrowe<usage>
6aa783d83f4304f664233d8252cb67116769676ewrowe <p>Specify the lifecycle scope of the Lua interpreter which will
6aa783d83f4304f664233d8252cb67116769676ewrowe be used by handlers in this "Directory." The default is "once"</p>
d8f54fe5534b61afa68100dddbe2eb98285d1100wrowe
18f36c8bdc74f9fd18739b9a154852c541b18900minfrin <dl>
18f36c8bdc74f9fd18739b9a154852c541b18900minfrin <dt>once:</dt> <dd>use the interpreter once and throw it away.</dd>
18f36c8bdc74f9fd18739b9a154852c541b18900minfrin
f1e73dbab9ba73d83c9ac8a13ab6150653bb71a9brianp <dt>request:</dt> <dd>use the interpreter to handle anything based on
f1e73dbab9ba73d83c9ac8a13ab6150653bb71a9brianp the same file within this request, which is also
7a01bcd2d59be7ec9ce55701c58054fa1c0bb5b6wrowe request scoped.</dd>
6aa783d83f4304f664233d8252cb67116769676ewrowe
6aa783d83f4304f664233d8252cb67116769676ewrowe <dt>conn:</dt> <dd>Same as request but attached to the connection_rec</dd>
6aa783d83f4304f664233d8252cb67116769676ewrowe
7a01bcd2d59be7ec9ce55701c58054fa1c0bb5b6wrowe <dt>server:</dt> <dd>This one is different than others because the
7a01bcd2d59be7ec9ce55701c58054fa1c0bb5b6wrowe server scope is quite long lived, and multiple threads
9d71a9210ee030534400d37010f34e6a7d72b53fnd will have the same server_rec. To accommodate this
9d71a9210ee030534400d37010f34e6a7d72b53fnd server scoped interpreter are stored in an apr
9d71a9210ee030534400d37010f34e6a7d72b53fnd resource list. The min and max arguments are intended
9d71a9210ee030534400d37010f34e6a7d72b53fnd to specify the pool size, but are unused at this time.</dd>
5d6ffa7b5c77dd4132ed6d7f0dd63548b1c3c1c9nd </dl>
5d6ffa7b5c77dd4132ed6d7f0dd63548b1c3c1c9nd</usage>
5d6ffa7b5c77dd4132ed6d7f0dd63548b1c3c1c9nd</directivesynopsis>
5d6ffa7b5c77dd4132ed6d7f0dd63548b1c3c1c9nd
5d6ffa7b5c77dd4132ed6d7f0dd63548b1c3c1c9nd<directivesynopsis>
144b1e2ebb48b2878017a8ac9a4cad1e771bc1b6stoddard<name>LuaMapHandler</name>
144b1e2ebb48b2878017a8ac9a4cad1e771bc1b6stoddard<description>Map a path to a lua handler</description>
144b1e2ebb48b2878017a8ac9a4cad1e771bc1b6stoddard<syntax>LuaMapHandler uri-pattern /path/to/lua/script.lua [function-name]</syntax>
74b84dd6e146edc93cf1b3200e411bfc581f7c36nd<contextlist><context>server config</context><context>virtual host</context>
143a04461642dea548a4bebdb302f5e411528a14trawick<context>directory</context><context>.htaccess</context>
143a04461642dea548a4bebdb302f5e411528a14trawick</contextlist>
143a04461642dea548a4bebdb302f5e411528a14trawick<override>All</override>
ebecc16986604cce1369d5075eff65032e3dd0deianh<usage>
ebecc16986604cce1369d5075eff65032e3dd0deianh <p>This directive matches a uri pattern to invoke a specific
ebecc16986604cce1369d5075eff65032e3dd0deianh handler function in a specific file. It uses PCRE regular
ebecc16986604cce1369d5075eff65032e3dd0deianh expressions to match the uri, and supports interpolating
ebecc16986604cce1369d5075eff65032e3dd0deianh match groups into both the file path and the function name
ebecc16986604cce1369d5075eff65032e3dd0deianh be careful writing your regular expressions to avoid security
ebecc16986604cce1369d5075eff65032e3dd0deianh issues.</p>
ebecc16986604cce1369d5075eff65032e3dd0deianh <example><title>Examples:</title>
7a2b9ea4788ea59d81b9e84192e4b90a9a0da875wrowe LuaMapHandler /(\w+)/(/w+) /scripts/$1.lua handle_$2
7a2b9ea4788ea59d81b9e84192e4b90a9a0da875wrowe </example>
7a2b9ea4788ea59d81b9e84192e4b90a9a0da875wrowe <p>This would match uri's such as /photos/show?id=9
7a2b9ea4788ea59d81b9e84192e4b90a9a0da875wrowe to the file /scripts/photos.lua and invoke the
7a2b9ea4788ea59d81b9e84192e4b90a9a0da875wrowe handler function handle_show on the lua vm after
d225a894172ec361d2c6791638bacf604a8c6fa4nd loading that file.</p>
d225a894172ec361d2c6791638bacf604a8c6fa4nd
d225a894172ec361d2c6791638bacf604a8c6fa4nd<example>
d225a894172ec361d2c6791638bacf604a8c6fa4nd LuaMapHandler /bingo /scripts/wombat.lua
d225a894172ec361d2c6791638bacf604a8c6fa4nd</example>
d225a894172ec361d2c6791638bacf604a8c6fa4nd <p>This would invoke the "handle" function, which
d225a894172ec361d2c6791638bacf604a8c6fa4nd is the default if no specific function name is
70f28b17978da5478a97843ab7cbcb4baf7a8711nd provided.</p>
70f28b17978da5478a97843ab7cbcb4baf7a8711nd</usage>
70f28b17978da5478a97843ab7cbcb4baf7a8711nd</directivesynopsis>
70f28b17978da5478a97843ab7cbcb4baf7a8711nd
ac539bd6714277d9ce7c39361de4cc11d1fb8eadnd<directivesynopsis>
ac539bd6714277d9ce7c39361de4cc11d1fb8eadnd<name>LuaPackagePath</name>
ac539bd6714277d9ce7c39361de4cc11d1fb8eadnd<description>Add a directory to lua's package.path</description>
f5208b93c14accca0cd5f5acb042332b20172fb1nd<syntax>LuaPackagePath /path/to/include/?.lua</syntax>
f5208b93c14accca0cd5f5acb042332b20172fb1nd<contextlist><context>server config</context><context>virtual host</context>
f5208b93c14accca0cd5f5acb042332b20172fb1nd<context>directory</context><context>.htaccess</context>
d8f54fe5534b61afa68100dddbe2eb98285d1100wrowe</contextlist>
1125f364c5cb4fd9bff71e89b5d4cbf551590035bnicholes<override>All</override>
1125f364c5cb4fd9bff71e89b5d4cbf551590035bnicholes <usage><p>Add a path to lua's module search path. Follows the same
1125f364c5cb4fd9bff71e89b5d4cbf551590035bnicholes conventions as lua. This just munges the package.path in the
1125f364c5cb4fd9bff71e89b5d4cbf551590035bnicholes lua vms.</p>
1125f364c5cb4fd9bff71e89b5d4cbf551590035bnicholes
1125f364c5cb4fd9bff71e89b5d4cbf551590035bnicholes <example><title>Examples:</title>
1125f364c5cb4fd9bff71e89b5d4cbf551590035bnicholes LuaPackagePath /scripts/lib/?.lua<br />
9d999c5deeddad9211695fc736a845afda6a2e95wrowe LuaPackagePath /scripts/lib/?/init.lua
9d999c5deeddad9211695fc736a845afda6a2e95wrowe </example>
9d999c5deeddad9211695fc736a845afda6a2e95wrowe</usage>
9d999c5deeddad9211695fc736a845afda6a2e95wrowe</directivesynopsis>
f19141958ebbfa8feb78e27007b4023d710d1c7etrawick
f19141958ebbfa8feb78e27007b4023d710d1c7etrawick<directivesynopsis>
f19141958ebbfa8feb78e27007b4023d710d1c7etrawick<name>LuaPackageCPath</name>
f19141958ebbfa8feb78e27007b4023d710d1c7etrawick<description>Add a directory to lua's package.cpath</description>
3ac9911bdb9c066a068041218d5b05bc851340bdtrawick<syntax>LuaPackageCPath /path/to/include/?.soa</syntax>
3ac9911bdb9c066a068041218d5b05bc851340bdtrawick<contextlist><context>server config</context><context>virtual host</context>
3ac9911bdb9c066a068041218d5b05bc851340bdtrawick<context>directory</context><context>.htaccess</context>
c5c445b5614e4d5040d3c0994d2456f1ac8cb9b5jerenkrantz</contextlist>
c5c445b5614e4d5040d3c0994d2456f1ac8cb9b5jerenkrantz<override>All</override>
c5c445b5614e4d5040d3c0994d2456f1ac8cb9b5jerenkrantz
c5c445b5614e4d5040d3c0994d2456f1ac8cb9b5jerenkrantz<usage>
c5c445b5614e4d5040d3c0994d2456f1ac8cb9b5jerenkrantz <p>Add a path to lua's shared library search path. Follows the same
c5c445b5614e4d5040d3c0994d2456f1ac8cb9b5jerenkrantz conventions as lua. This just munges the package.cpath in the
5541a81e194dc99521c0ecf904a940b0b65a93f2nd lua vms.</p>
5541a81e194dc99521c0ecf904a940b0b65a93f2nd
5541a81e194dc99521c0ecf904a940b0b65a93f2nd</usage>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe</directivesynopsis>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<directivesynopsis>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<name>LuaCodeCache</name>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<description>Configure the compiled code cache.</description>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<syntax>LuaCodeCache stat|forever|never</syntax>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<default>LuaCodeCache stat</default>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<contextlist><context>server config</context><context>virtual host</context>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<context>directory</context><context>.htaccess</context>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe</contextlist>
f16b2c3124a11bff93724342099e1afdb8145917bnicholes<override>All</override>
f16b2c3124a11bff93724342099e1afdb8145917bnicholes
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe<usage><p>
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe Specify the behavior of the in-memory code cache. The default
60736084c3e45fe7ece48483188e58b0f9e3a36bwrowe is stat, which stats the top level script (not any included
f16b2c3124a11bff93724342099e1afdb8145917bnicholes ones) each time that file is needed, and reloads it if the
d584e3b7a33da68233e7ac403213b436b402f5bend modified time indicates it is newer than the one it has
d584e3b7a33da68233e7ac403213b436b402f5bend already loaded. The other values cause it to keep the file
d584e3b7a33da68233e7ac403213b436b402f5bend cached forever (don't stat and replace) or to never cache the
d584e3b7a33da68233e7ac403213b436b402f5bend file.</p>
d584e3b7a33da68233e7ac403213b436b402f5bend
d584e3b7a33da68233e7ac403213b436b402f5bend <p>In general stat or forever is good for production, and stat or never
d584e3b7a33da68233e7ac403213b436b402f5bend for development.</p>
d584e3b7a33da68233e7ac403213b436b402f5bend
d584e3b7a33da68233e7ac403213b436b402f5bend <example><title>Examples:</title>
d584e3b7a33da68233e7ac403213b436b402f5bend LuaCodeCache stat<br />
d584e3b7a33da68233e7ac403213b436b402f5bend LuaCodeCache forever<br />
d584e3b7a33da68233e7ac403213b436b402f5bend LuaCodeCache never<br />
d584e3b7a33da68233e7ac403213b436b402f5bend </example>
d584e3b7a33da68233e7ac403213b436b402f5bend
d584e3b7a33da68233e7ac403213b436b402f5bend</usage>
d584e3b7a33da68233e7ac403213b436b402f5bend</directivesynopsis>
d584e3b7a33da68233e7ac403213b436b402f5bend
d584e3b7a33da68233e7ac403213b436b402f5bend<directivesynopsis>
d584e3b7a33da68233e7ac403213b436b402f5bend<name>LuaHookTranslateName</name>
d584e3b7a33da68233e7ac403213b436b402f5bend<description>Provide a hook for the translate name phase of request processing</description>
3e49fe84a5024d831ffb14697747c5948821f958trawick<syntax>LuaHookTranslateName /path/to/lua/script.lua hook_function_name</syntax>
3e49fe84a5024d831ffb14697747c5948821f958trawick<contextlist><context>server config</context><context>virtual host</context>
3e49fe84a5024d831ffb14697747c5948821f958trawick<context>directory</context><context>.htaccess</context>
5610fc134df70e725bcdef518cc93de70261eb1dnd</contextlist>
5610fc134df70e725bcdef518cc93de70261eb1dnd<override>All</override>
5610fc134df70e725bcdef518cc93de70261eb1dnd
5610fc134df70e725bcdef518cc93de70261eb1dnd<usage><p>
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick Add a hook (at APR_HOOK_MIDDLE) to the translate name phase of
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick request processing. The hook function receives a single
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick argument, the request_rec, and should return a status code,
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick which is either an HTTP error code, or the constants defined
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick in the apache2 module: apache2.OK, apache2.DECLINED, or
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick apache2.DONE. </p>
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick <p>For those new to hooks, basically each hook will be invoked
965680cd7c050ec8c8c751ffdbaf19c91213d562trawick until one of them returns apache2.OK. If your hook doesn't
52d61f96a186861d991583851218e15ea16f0abetrawick want to do the translation it should just return
52d61f96a186861d991583851218e15ea16f0abetrawick apache2.DECLINED. If the request should stop processing, then
52d61f96a186861d991583851218e15ea16f0abetrawick return apache2.DONE.</p>
52d61f96a186861d991583851218e15ea16f0abetrawick
4fa5f4378779a06834ec5efa44810f93741c5f27wrowe <p>Example:</p>
4fa5f4378779a06834ec5efa44810f93741c5f27wrowe
4fa5f4378779a06834ec5efa44810f93741c5f27wrowe<example><pre>
4fa5f4378779a06834ec5efa44810f93741c5f27wrowe# httpd.conf
6838d0e05a193cb77265db36e3549201b3df57e6wroweLuaHookTranslateName /scripts/conf/hooks.lua silly_mapper
74b84dd6e146edc93cf1b3200e411bfc581f7c36nd
74b84dd6e146edc93cf1b3200e411bfc581f7c36nd-- /scripts/conf/hooks.lua --
74b84dd6e146edc93cf1b3200e411bfc581f7c36ndrequire "apache2"
11e365512cbf021726cd3ec3d80743f408170ff9stoddardfunction silly_mapper(r)
11e365512cbf021726cd3ec3d80743f408170ff9stoddard if r.uri == "/" then
11e365512cbf021726cd3ec3d80743f408170ff9stoddard r.file = "/var/www/home.lua"
11e365512cbf021726cd3ec3d80743f408170ff9stoddard return apache2.OK
11e365512cbf021726cd3ec3d80743f408170ff9stoddard else
367cefc17f8dcfe65651c9c16cb3151589c6cecetrawick return apache2.DECLINED
2774f23eee36fdb1b30a8213bbcabe5336175e54jwoolley end
2774f23eee36fdb1b30a8213bbcabe5336175e54jwoolleyend
2774f23eee36fdb1b30a8213bbcabe5336175e54jwoolley</pre></example>
2774f23eee36fdb1b30a8213bbcabe5336175e54jwoolley</usage>
1944ddbbad413b60307d66081b022a3eee5f04cfbnicholes</directivesynopsis>
1944ddbbad413b60307d66081b022a3eee5f04cfbnicholes
1944ddbbad413b60307d66081b022a3eee5f04cfbnicholes<directivesynopsis>
1944ddbbad413b60307d66081b022a3eee5f04cfbnicholes<name>LuaHookFixups</name>
3b1dc8f8f153d7167da9e64ab44f3e90f486a458wrowe<description>Provide a hook for the fixups phase of request
3b1dc8f8f153d7167da9e64ab44f3e90f486a458wroweprocessing</description>
3b1dc8f8f153d7167da9e64ab44f3e90f486a458wrowe<syntax>LuaHookFixups /path/to/lua/script.lua hook_function_name</syntax>
3b1dc8f8f153d7167da9e64ab44f3e90f486a458wrowe<contextlist><context>server config</context><context>virtual host</context>
2404b81d39a1a539f980d4808d52d23997a9e006nd<context>directory</context><context>.htaccess</context>
2404b81d39a1a539f980d4808d52d23997a9e006nd</contextlist>
2404b81d39a1a539f980d4808d52d23997a9e006nd<override>All</override>
a3754e9d2edd5758f94fd743b9cf9f814be80383nd<usage>
a3754e9d2edd5758f94fd743b9cf9f814be80383nd<p>
a3754e9d2edd5758f94fd743b9cf9f814be80383nd Just like LuaHookTranslateName, but executed at the fixups phase
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick</p>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick</usage>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick</directivesynopsis>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick<directivesynopsis>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick<name>LuaHookMapToStorage</name>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick<description>Provide a hook for the map_to_storage phase of request processing</description>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick<syntax>LuaHookMapToStorage /path/to/lua/script.lua hook_function_name</syntax>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick<contextlist><context>server config</context><context>virtual host</context>
f9a987f71572291f35b9d0adc3fe79af96b2b147trawick<context>directory</context><context>.htaccess</context>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe</contextlist>
5c870e08d589a24283cd76a9d596120605762cbbminfrin<override>All</override>
5c870e08d589a24283cd76a9d596120605762cbbminfrin <usage><p>...</p></usage>
5c870e08d589a24283cd76a9d596120605762cbbminfrin</directivesynopsis>
47d4dfaca60aff6d3c7e591bf593b3961cafcdefminfrin
47d4dfaca60aff6d3c7e591bf593b3961cafcdefminfrin<directivesynopsis>
47d4dfaca60aff6d3c7e591bf593b3961cafcdefminfrin<name>LuaHookCheckUserID</name>
c206205e2475a7a4a192eaa7190a9894f01f0631minfrin<description>Provide a hook for the check_user_id phase of request processing</description>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe<syntax>LuaHookCheckUserID /path/to/lua/script.lua hook_function_name</syntax>
c206205e2475a7a4a192eaa7190a9894f01f0631minfrin<contextlist><context>server config</context><context>virtual host</context>
c206205e2475a7a4a192eaa7190a9894f01f0631minfrin<context>directory</context><context>.htaccess</context>
304aee4b1ff85cc876570493e4ed334d42b4d9eftrawick</contextlist>
304aee4b1ff85cc876570493e4ed334d42b4d9eftrawick<override>All</override>
304aee4b1ff85cc876570493e4ed334d42b4d9eftrawick <usage><p>...</p></usage>
304aee4b1ff85cc876570493e4ed334d42b4d9eftrawick</directivesynopsis>
304aee4b1ff85cc876570493e4ed334d42b4d9eftrawick
304aee4b1ff85cc876570493e4ed334d42b4d9eftrawick<directivesynopsis>
77582a85f880a10e8e225ecd5b303446d23d1c9atrawick<name>LuaHookTypeChecker</name>
77582a85f880a10e8e225ecd5b303446d23d1c9atrawick<description>Provide a hook for the type_checker phase of request processing</description>
77582a85f880a10e8e225ecd5b303446d23d1c9atrawick<syntax>LuaHookTypeChecker /path/to/lua/script.lua hook_function_name</syntax>
77582a85f880a10e8e225ecd5b303446d23d1c9atrawick<contextlist><context>server config</context><context>virtual host</context>
77582a85f880a10e8e225ecd5b303446d23d1c9atrawick<context>directory</context><context>.htaccess</context>
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe</contextlist>
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe<override>All</override>
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe <usage><p>...</p></usage>
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe</directivesynopsis>
111b2312c9749936ebca4f273db445820a0a703ebrianp
111b2312c9749936ebca4f273db445820a0a703ebrianp<directivesynopsis>
6838d0e05a193cb77265db36e3549201b3df57e6wrowe<name>LuaHookAuthChecker</name>
ad877cddc14be8c8171938ba61338c6c7b896bbdtrawick<description>Provide a hook for the auth_checker phase of request processing</description>
ad877cddc14be8c8171938ba61338c6c7b896bbdtrawick<syntax>LuaHookAuthChecker /path/to/lua/script.lua hook_function_name</syntax>
ad877cddc14be8c8171938ba61338c6c7b896bbdtrawick<contextlist><context>server config</context><context>virtual host</context>
ad877cddc14be8c8171938ba61338c6c7b896bbdtrawick<context>directory</context><context>.htaccess</context>
ad877cddc14be8c8171938ba61338c6c7b896bbdtrawick</contextlist>
ad877cddc14be8c8171938ba61338c6c7b896bbdtrawick<override>All</override>
367cefc17f8dcfe65651c9c16cb3151589c6cecetrawick<usage>
367cefc17f8dcfe65651c9c16cb3151589c6cecetrawick<p>Invoke a lua function in the auth_checker phase of processing
367cefc17f8dcfe65651c9c16cb3151589c6cecetrawicka request. This can be used to implement arbitrary authentication
367cefc17f8dcfe65651c9c16cb3151589c6cecetrawickand authorization checking. A very simple example:
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe</p>
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe<example><pre>
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowerequire 'apache2'
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe-- fake authcheck hook
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe-- If request has no auth info, set the response header and
f49cf8ce86a01c90d5d843fc27e19d2802dd0f77wrowe-- return a 401 to ask the browser for basic auth info.
9b867bfaea269f387a0cf2aa4c9f38d4d51bac94rederpj-- If request has auth info, don't actually look at it, just
9b867bfaea269f387a0cf2aa4c9f38d4d51bac94rederpj-- pretend we got userid 'foo' and validated it.
9b867bfaea269f387a0cf2aa4c9f38d4d51bac94rederpj-- Then check if the userid is 'foo' and accept the request.
9b867bfaea269f387a0cf2aa4c9f38d4d51bac94rederpjfunction authcheck_hook(r)
9b867bfaea269f387a0cf2aa4c9f38d4d51bac94rederpj
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe -- look for auth info
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe auth = r.headers_in['Authorization']
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe if auth ~= nil then
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe -- fake the user
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe r.user = 'foo'
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe end
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe if r.user == nil then
52435ceaabd1670b2c3a062acc191159a64fb7a1wrowe r:debug("authcheck: user is nil, returning 401")
e199d79647c689a85951f19b08a08082263f4df8brianp r.err_headers_out['WWW-Authenticate'] = 'Basic realm="WallyWorld"'
e199d79647c689a85951f19b08a08082263f4df8brianp return 401
e199d79647c689a85951f19b08a08082263f4df8brianp elseif r.user == "foo" then
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe r:debug('user foo: OK')
6838d0e05a193cb77265db36e3549201b3df57e6wrowe else
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe r:debug("authcheck: user='" .. r.user .. "'")
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe r.err_headers_out['WWW-Authenticate'] = 'Basic realm="WallyWorld"'
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe return 401
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe end
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe return apache2.OK
ad451e2e428a069086d1c18c9e3372f8846ec617wroweend
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe</pre></example>
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe</usage>
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe</directivesynopsis>
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe<directivesynopsis>
ad451e2e428a069086d1c18c9e3372f8846ec617wrowe<name>LuaHookAccessChecker</name>
1e1e5c477f92840ffbcb8acd0003305022e5468atrawick<description>Provide a hook for the access_checker phase of request processing</description>
1e1e5c477f92840ffbcb8acd0003305022e5468atrawick<syntax>LuaHookAccessChecker /path/to/lua/script.lua hook_function_name</syntax>
1e1e5c477f92840ffbcb8acd0003305022e5468atrawick<contextlist><context>server config</context><context>virtual host</context>
1e1e5c477f92840ffbcb8acd0003305022e5468atrawick<context>directory</context><context>.htaccess</context>
1e1e5c477f92840ffbcb8acd0003305022e5468atrawick</contextlist>
1e1e5c477f92840ffbcb8acd0003305022e5468atrawick<override>All</override>
c998c5be82bf2b41f8fc27de9376ba10651c74bcrederpj<usage>
c998c5be82bf2b41f8fc27de9376ba10651c74bcrederpj<p>Add your hook to the access_checker phase. An access checker
c998c5be82bf2b41f8fc27de9376ba10651c74bcrederpjhook function usually returns OK, DECLINED, or HTTP_FORBIDDEN.</p>
c998c5be82bf2b41f8fc27de9376ba10651c74bcrederpj</usage>
c998c5be82bf2b41f8fc27de9376ba10651c74bcrederpj</directivesynopsis>
c998c5be82bf2b41f8fc27de9376ba10651c74bcrederpj
58eb8d7cca552570577aa8b636349a695ff193datrawick<directivesynopsis>
58eb8d7cca552570577aa8b636349a695ff193datrawick<name>LuaHookInsertFilter</name>
58eb8d7cca552570577aa8b636349a695ff193datrawick<description>Provide a hook for the insert_filter phase of request processing</description>
58eb8d7cca552570577aa8b636349a695ff193datrawick<syntax>LuaHookInsertFilter /path/to/lua/script.lua hook_function_name</syntax>
ecf435f0c6379df7ed83285d5597fc9aa39c6f6dbrianp<contextlist><context>server config</context><context>virtual host</context>
ecf435f0c6379df7ed83285d5597fc9aa39c6f6dbrianp<context>directory</context><context>.htaccess</context>
ecf435f0c6379df7ed83285d5597fc9aa39c6f6dbrianp</contextlist>
ecf435f0c6379df7ed83285d5597fc9aa39c6f6dbrianp<override>All</override>
480f2a1b2fb27a8284e66e60a5bbaee6bc1ccb04trawick <usage><p>Not Yet Implemented</p></usage>
480f2a1b2fb27a8284e66e60a5bbaee6bc1ccb04trawick</directivesynopsis>
480f2a1b2fb27a8284e66e60a5bbaee6bc1ccb04trawick
480f2a1b2fb27a8284e66e60a5bbaee6bc1ccb04trawick<directivesynopsis>
acc9093ae1f3c97acc635bd5b2c7c0969da21183trawick<name>LuaQuickHandler</name>
acc9093ae1f3c97acc635bd5b2c7c0969da21183trawick<description>Provide a hook for the quick handler of request processing</description>
acc9093ae1f3c97acc635bd5b2c7c0969da21183trawick<syntax></syntax>
2fa5f4c38890220c6ea439317e7dcb9e8b3c76f7jwoolley<contextlist><context>server config</context><context>virtual host</context>
2fa5f4c38890220c6ea439317e7dcb9e8b3c76f7jwoolley<context>directory</context><context>.htaccess</context>
2fa5f4c38890220c6ea439317e7dcb9e8b3c76f7jwoolley</contextlist>
95d00ea81131488769296fa5765ed745cbf45207trawick<override>All</override>
95d00ea81131488769296fa5765ed745cbf45207trawick<usage><p>...</p></usage>
95d00ea81131488769296fa5765ed745cbf45207trawick</directivesynopsis>
95d00ea81131488769296fa5765ed745cbf45207trawick
95d00ea81131488769296fa5765ed745cbf45207trawick</modulesynopsis>
95d00ea81131488769296fa5765ed745cbf45207trawick
95d00ea81131488769296fa5765ed745cbf45207trawick