mod_lua.html.en revision fc57cc74ee4e73618f74a7a62ea6ac77546666da
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<?xml version="1.0" encoding="ISO-8859-1"?>
fb51a6b789d85113d0976148685b0063c294220drbowen<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
77a0265761f1bec2aaa0b4116c644f8066e349e3rbowen XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen This file is generated from xml source: DO NOT EDIT
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen -->
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<title>mod_lua - Apache HTTP Server</title>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<link href="/images/favicon.ico" rel="shortcut icon" /></head>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<body>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<div id="page-header">
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<p class="apache">Apache HTTP Server Version 2.3</p>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<img alt="" src="/images/feather.gif" /></div>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<div id="path">
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.3</a> &gt; <a href="./">Modules</a></div>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<div id="page-content">
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<div id="preamble"><h1>Apache Module mod_lua</h1>
b07b82e44c32825d6226ee801d2ed91555e593d1rbowen<div class="toplang">
fb51a6b789d85113d0976148685b0063c294220drbowen<p><span>Available Languages: </span><a href="/en/mod/mod_lua.html" title="English">&nbsp;en&nbsp;</a></p>
fb51a6b789d85113d0976148685b0063c294220drbowen</div>
fb51a6b789d85113d0976148685b0063c294220drbowen<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides Lua hooks into various portions of the httpd
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowenrequest processing</td></tr>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>lua_module</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_lua.c</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>2.3 and later</td></tr></table>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<h3>Summary</h3>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen<p>This module allows the server to be extended with scripts written in the
92e5d4326ae44f79da5cb049470daba604506846poirierLua programming language. The extension points (hooks) available with
92e5d4326ae44f79da5cb049470daba604506846poirier<code class="module"><a href="/mod/mod_lua.html">mod_lua</a></code> include many of the hooks available to
92e5d4326ae44f79da5cb049470daba604506846poiriernatively compiled Apache HTTP Server modules, such as mapping requests to
fb51a6b789d85113d0976148685b0063c294220drbowenfiles, generating dynamic responses, access control, authentication, and
fb51a6b789d85113d0976148685b0063c294220drbowenauthorization</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<p>More information on the Lua programming language can be found at the
fb51a6b789d85113d0976148685b0063c294220drbowen<a href="http://www.lua.org/">the Lua website</a>.</p>
3e30fa5f420fe7302a4cdcd79cb001958fd54a13rbowen
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="note"><code>mod_lua</code> is still in experimental state.
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowenUntil it is declared stable, usage and behavior may change
2219c51bf0756c2f6f7deb88a13baf30f141c12epoirierat any time.</div>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen
fb51a6b789d85113d0976148685b0063c294220drbowen</div>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<div id="quickview"><h3 class="directives">Directives</h3>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<ul id="toc">
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<li><img alt="" src="/images/down.gif" /> <a href="#luacodecache">LuaCodeCache</a></li>
fb51a6b789d85113d0976148685b0063c294220drbowen<li><img alt="" src="/images/down.gif" /> <a href="#luahookaccesschecker">LuaHookAccessChecker</a></li>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<li><img alt="" src="/images/down.gif" /> <a href="#luahookauthchecker">LuaHookAuthChecker</a></li>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<li><img alt="" src="/images/down.gif" /> <a href="#luahookcheckuserid">LuaHookCheckUserID</a></li>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<li><img alt="" src="/images/down.gif" /> <a href="#luahookfixups">LuaHookFixups</a></li>
fb51a6b789d85113d0976148685b0063c294220drbowen<li><img alt="" src="/images/down.gif" /> <a href="#luahookinsertfilter">LuaHookInsertFilter</a></li>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<li><img alt="" src="/images/down.gif" /> <a href="#luahookmaptostorage">LuaHookMapToStorage</a></li>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<li><img alt="" src="/images/down.gif" /> <a href="#luahooktranslatename">LuaHookTranslateName</a></li>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<li><img alt="" src="/images/down.gif" /> <a href="#luahooktypechecker">LuaHookTypeChecker</a></li>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<li><img alt="" src="/images/down.gif" /> <a href="#luamaphandler">LuaMapHandler</a></li>
4b2d52ed83bf31730c8b6bbe7c06d806dc3a0c4erbowen<li><img alt="" src="/images/down.gif" /> <a href="#luapackagecpath">LuaPackageCPath</a></li>
92e5d4326ae44f79da5cb049470daba604506846poirier<li><img alt="" src="/images/down.gif" /> <a href="#luapackagepath">LuaPackagePath</a></li>
92e5d4326ae44f79da5cb049470daba604506846poirier<li><img alt="" src="/images/down.gif" /> <a href="#luaquickhandler">LuaQuickHandler</a></li>
92e5d4326ae44f79da5cb049470daba604506846poirier<li><img alt="" src="/images/down.gif" /> <a href="#luaroot">LuaRoot</a></li>
92e5d4326ae44f79da5cb049470daba604506846poirier<li><img alt="" src="/images/down.gif" /> <a href="#luascope">LuaScope</a></li>
fb51a6b789d85113d0976148685b0063c294220drbowen</ul>
fb51a6b789d85113d0976148685b0063c294220drbowen<h3>Topics</h3>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<ul id="topics">
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<li><img alt="" src="/images/down.gif" /> <a href="#basicconf">Basic Configuration</a></li>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<li><img alt="" src="/images/down.gif" /> <a href="#writinghandlers">Writing Handlers</a></li>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<li><img alt="" src="/images/down.gif" /> <a href="#writinghooks">Writing Hooks</a></li>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<li><img alt="" src="/images/down.gif" /> <a href="#datastructures">Data Structures</a></li>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<li><img alt="" src="/images/down.gif" /> <a href="#logging">Logging Functions</a></li>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<li><img alt="" src="/images/down.gif" /> <a href="#apache2">apache2 Package</a></li>
92e5d4326ae44f79da5cb049470daba604506846poirier</ul></div>
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="section">
92e5d4326ae44f79da5cb049470daba604506846poirier<h2><a name="basicconf" id="basicconf">Basic Configuration</a></h2>
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier<p>The basic module loading directive is</p>
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="example"><p><code>
92e5d4326ae44f79da5cb049470daba604506846poirier LoadModule lua_module modules/mod_lua.so
92e5d4326ae44f79da5cb049470daba604506846poirier</code></p></div>
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier<p>
92e5d4326ae44f79da5cb049470daba604506846poirier<code>mod_lua</code> provides a handler named <code>lua-script</code>,
92e5d4326ae44f79da5cb049470daba604506846poirierwhich can be used with an <code>AddHandler</code> directive:</p>
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="example"><p><code>
92e5d4326ae44f79da5cb049470daba604506846poirierAddHandler lua-script .lua
92e5d4326ae44f79da5cb049470daba604506846poirier</code></p></div>
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier<p>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowenThis will cause <code>mod_lua</code> to handle requests for files
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowenending in <code>.lua</code> by invoking that file's
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<code>handle</code> function.
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen</p>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<p>For more flexibility, see <code class="directive">LuaMapHandler</code>.
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen</p>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<div class="section">
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<h2><a name="writinghandlers" id="writinghandlers">Writing Handlers</a></h2>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen<p> In the Apache HTTP Server API, the handler is a specific kind of hook
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowenresponsible for generating the response. Examples of modules that include a
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowenhandler are <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code>, <code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code>,
92e5d4326ae44f79da5cb049470daba604506846poirierand <code class="module"><a href="/mod/mod_status.html">mod_status</a></code>.</p>
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier<p><code>mod_lua</code> always looks to invoke a Lua function for the handler, rather than
92e5d4326ae44f79da5cb049470daba604506846poirierjust evaluating a script body CGI style. A handler function looks
92e5d4326ae44f79da5cb049470daba604506846poiriersomething like this:</p>
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="example"><h3>example.lua</h3><pre>
92e5d4326ae44f79da5cb049470daba604506846poirier-- example handler
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirierrequire "string"
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier--[[
92e5d4326ae44f79da5cb049470daba604506846poirier This is the default method name for Lua handlers, see the optional
92e5d4326ae44f79da5cb049470daba604506846poirier function-name in the LuaMapHandler directive to choose a different
92e5d4326ae44f79da5cb049470daba604506846poirier entry point.
92e5d4326ae44f79da5cb049470daba604506846poirier--]]
92e5d4326ae44f79da5cb049470daba604506846poirierfunction handle(r)
92e5d4326ae44f79da5cb049470daba604506846poirier r.content_type = "text/plain"
92e5d4326ae44f79da5cb049470daba604506846poirier r:puts("Hello Lua World!\n")
92e5d4326ae44f79da5cb049470daba604506846poirier
92e5d4326ae44f79da5cb049470daba604506846poirier if r.method == 'GET' then
92e5d4326ae44f79da5cb049470daba604506846poirier for k, v in pairs( r:parseargs() ) do
92e5d4326ae44f79da5cb049470daba604506846poirier r:puts( string.format("%s: %s", k, v) )
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen end
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen elseif r.method == 'POST' then
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen for k, v in pairs( r:parsebody() ) do
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen r:puts( string.format("%s: %s", k, v) )
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen end
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen else
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen r:puts("unknown HTTP method " .. r.method)
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen end
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowenend
92e5d4326ae44f79da5cb049470daba604506846poirier</pre></div>
92e5d4326ae44f79da5cb049470daba604506846poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<p>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierThis handler function just prints out the uri or form encoded
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierarguments to a plaintext page.
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier</p>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<p>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierThis means (and in fact encourages) that you can have multiple
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierhandlers (or hooks, or filters) in the same script.
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier</p>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<div class="section">
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<h2><a name="writinghooks" id="writinghooks">Writing Hooks</a></h2>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<p>Hook functions are how modules (and Lua scripts) participate in the
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierprocessing of requests. Each type of hook exposed by the server exists for
249cc9b3d83d3c60666269b90ecb9f1390d32165poiriera specific purposes such as mapping requests to the filesystem,
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierperforming access control, or setting mimetypes. General purpose hooks
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierthat simply run at handy times in the request lifecycle exist as well.</p>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<p>Hook functions are passed the request object as their only argument.
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierThey can return any value, depending on the hook, but most commonly
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierthey'll return OK, DONE, or DECLINED, which you can write in lua as
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<code>apache2.OK</code>, <code>apache2.DONE</code>, or
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<code>apache2.DECLINED</code>, or else an HTTP status code.</p>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<div class="example"><h3>translate_name.lua</h3><pre>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier-- example hook that rewrites the URI to a filesystem path.
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierrequire 'apache2'
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierfunction translate_name(r)
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier if r.uri == "/translate-name" then
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier r.filename = r.document_root .. "/find_me.txt"
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier return apache2.OK
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier end
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier -- we don't care about this URL, give another module a chance
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier return apache2.DECLINED
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierend
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier</pre></div>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<div class="example"><h3>translate_name2.lua</h3><pre>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier--[[ example hook that rewrites one URI to another URI. It returns a
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier apache2.DECLINED to give other URL mappers a chance to work on the
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier substitution, including the core translate_name hook which maps based
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier on the DocumentRoot.
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier Note: It is currently undefined as to whether this runs before or after
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier mod_alias.
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier--]]
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierrequire 'apache2'
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierfunction translate_name(r)
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier if r.uri == "/translate-name" then
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier r.uri = "/find_me.txt"
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier return apache2.DECLINED
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier end
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier return apache2.DECLINED
249cc9b3d83d3c60666269b90ecb9f1390d32165poirierend
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier</pre></div>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<div class="section">
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<h2><a name="datastructures" id="datastructures">Data Structures</a></h2>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<dl>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier<dt>request_rec</dt>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <dd>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <p>The request_rec is mapped in as a userdata. It has a metatable
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier which lets you do useful things with it. For the most part it
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier has the same fields as the request_rec struct (see httpd.h
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier until we get better docs here) many of which are writeable as
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier well as readable. (The table fields' content can be changed, but the
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier fields themselves cannot be set to different tables.)</p>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <table class="bordered">
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
92e5d4326ae44f79da5cb049470daba604506846poirier <th><strong>Name</strong></th>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <th><strong>Lua type</strong></th>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <th><strong>Writable</strong></th>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>ap_auth_type</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>args</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>yes</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>assbackwards</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>boolean</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>canonical_filename</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>content_encoding</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>content_type</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>yes</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>document_root</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>err_headers_out</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>table</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>filename</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>yes</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>headers_in</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>table</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>yes</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>headers_out</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>table</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>yes</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen </tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td><code>hostname</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td><code>method</code></td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>string</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>no</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen </tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td><code>notes</code></td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>table</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>yes</td>
92e5d4326ae44f79da5cb049470daba604506846poirier </tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td><code>path_info</code></td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>string</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>no</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen </tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td><code>protocol</code></td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>string</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td>no</td>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen </tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <tr>
e27eee5caa6c1bf3853c11253ae82303cff0e40brbowen <td><code>range</code></td>
92e5d4326ae44f79da5cb049470daba604506846poirier <td>string</td>
92e5d4326ae44f79da5cb049470daba604506846poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>subprocess_env</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>table</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>yes</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>status</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>number</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>yes</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td><code>the_request</code></td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <td>string</td>
92e5d4326ae44f79da5cb049470daba604506846poirier <td>no</td>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier </tr>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier <tr>
fb51a6b789d85113d0976148685b0063c294220drbowen <td><code>unparsed_uri</code></td>
fb51a6b789d85113d0976148685b0063c294220drbowen <td>string</td>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen <td>no</td>
fb51a6b789d85113d0976148685b0063c294220drbowen </tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic <tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic <td><code>uri</code></td>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic <td>string</td>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic <td>yes</td>
fb51a6b789d85113d0976148685b0063c294220drbowen </tr>
fb51a6b789d85113d0976148685b0063c294220drbowen <tr>
fb51a6b789d85113d0976148685b0063c294220drbowen <td><code>user</code></td>
2219c51bf0756c2f6f7deb88a13baf30f141c12epoirier <td>string</td>
fb51a6b789d85113d0976148685b0063c294220drbowen <td>yes</td>
fb51a6b789d85113d0976148685b0063c294220drbowen </tr>
fb51a6b789d85113d0976148685b0063c294220drbowen </table>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen <p>The request_rec has (at least) the following methods:</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen <div class="example"><p><code>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen r:addoutputfilter(name|function) -- add an output filter
fb51a6b789d85113d0976148685b0063c294220drbowen </code></p></div>
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic <div class="example"><p><code>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic r:parseargs() -- returns a lua table containing the request's
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic query string arguments
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic </code></p></div>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen <div class="example"><p><code>
fb51a6b789d85113d0976148685b0063c294220drbowen r:parsebody() -- parse the request body as a POST and return
c994f52ac80f9664d2940e5ccd9e77466572013frbowen a lua table
c994f52ac80f9664d2940e5ccd9e77466572013frbowen </code></p></div>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen
c994f52ac80f9664d2940e5ccd9e77466572013frbowen <div class="example"><p><code>
fb51a6b789d85113d0976148685b0063c294220drbowen r:puts("hello", " world", "!") -- print to response body
c994f52ac80f9664d2940e5ccd9e77466572013frbowen </code></p></div>
fb51a6b789d85113d0976148685b0063c294220drbowen
c994f52ac80f9664d2940e5ccd9e77466572013frbowen <div class="example"><p><code>
fb51a6b789d85113d0976148685b0063c294220drbowen r:write("a single string") -- print to response body
c994f52ac80f9664d2940e5ccd9e77466572013frbowen </code></p></div>
fb51a6b789d85113d0976148685b0063c294220drbowen </dd>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen </dl>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="section">
fb51a6b789d85113d0976148685b0063c294220drbowen<h2><a name="logging" id="logging">Logging Functions</a></h2>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen
c994f52ac80f9664d2940e5ccd9e77466572013frbowen<div class="example"><p><code>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen -- examples of logging messages<br />
fb51a6b789d85113d0976148685b0063c294220drbowen r:trace1("This is a trace log message") -- trace1 through trace8 can be used <br />
fb51a6b789d85113d0976148685b0063c294220drbowen r:debug("This is a debug log message")<br />
fb51a6b789d85113d0976148685b0063c294220drbowen r:info("This is an info log message")<br />
fb51a6b789d85113d0976148685b0063c294220drbowen r:notice("This is an notice log message")<br />
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen r:warn("This is an warn log message")<br />
fb51a6b789d85113d0976148685b0063c294220drbowen r:err("This is an err log message")<br />
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic r:alert("This is an alert log message")<br />
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic r:crit("This is an crit log message")<br />
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic r:emerg("This is an emerg log message")<br />
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic</code></p></div>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="section">
fb51a6b789d85113d0976148685b0063c294220drbowen<h2><a name="apache2" id="apache2">apache2 Package</a></h2>
fb51a6b789d85113d0976148685b0063c294220drbowen<p>A package named <code>apache2</code> is available with (at least) the following contents.</p>
fb51a6b789d85113d0976148685b0063c294220drbowen<dl>
fb51a6b789d85113d0976148685b0063c294220drbowen <dt>apache2.OK</dt>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen <dd>internal constant OK. Handlers should return this if they've
fb51a6b789d85113d0976148685b0063c294220drbowen handled the request.</dd>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen <dt>apache2.DECLINED</dt>
fb51a6b789d85113d0976148685b0063c294220drbowen <dd>internal constant DECLINED. Handlers should return this if
fb51a6b789d85113d0976148685b0063c294220drbowen they are not going to handle the request.</dd>
fb51a6b789d85113d0976148685b0063c294220drbowen <dt>apache2.DONE</dt>
fb51a6b789d85113d0976148685b0063c294220drbowen <dd>internal constant DONE.</dd>
fb51a6b789d85113d0976148685b0063c294220drbowen <dt>apache2.version</dt>
fb51a6b789d85113d0976148685b0063c294220drbowen <dd>Apache HTTP server version string</dd>
fb51a6b789d85113d0976148685b0063c294220drbowen <dt>apache2.HTTP_MOVED_TEMPORARILY</dt>
fb51a6b789d85113d0976148685b0063c294220drbowen <dd>HTTP status code</dd>
fb51a6b789d85113d0976148685b0063c294220drbowen</dl>
fb51a6b789d85113d0976148685b0063c294220drbowen<p>(Other HTTP status codes are not yet implemented.)</p>
fb51a6b789d85113d0976148685b0063c294220drbowen</div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="directive-section"><h2><a name="LuaCodeCache" id="LuaCodeCache">LuaCodeCache</a> <a name="luacodecache" id="luacodecache">Directive</a></h2>
fb51a6b789d85113d0976148685b0063c294220drbowen<table class="directive">
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Configure the compiled code cache.</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaCodeCache stat|forever|never</code></td></tr>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LuaCodeCache stat</code></td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic</table><p>
fb51a6b789d85113d0976148685b0063c294220drbowen Specify the behavior of the in-memory code cache. The default
fb51a6b789d85113d0976148685b0063c294220drbowen is stat, which stats the top level script (not any included
c994f52ac80f9664d2940e5ccd9e77466572013frbowen ones) each time that file is needed, and reloads it if the
fb51a6b789d85113d0976148685b0063c294220drbowen modified time indicates it is newer than the one it has
c994f52ac80f9664d2940e5ccd9e77466572013frbowen already loaded. The other values cause it to keep the file
c994f52ac80f9664d2940e5ccd9e77466572013frbowen cached forever (don't stat and replace) or to never cache the
fb51a6b789d85113d0976148685b0063c294220drbowen file.</p>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen
c994f52ac80f9664d2940e5ccd9e77466572013frbowen <p>In general stat or forever is good for production, and stat or never
fb51a6b789d85113d0976148685b0063c294220drbowen for development.</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen <div class="example"><h3>Examples:</h3><p><code>
fb51a6b789d85113d0976148685b0063c294220drbowen LuaCodeCache stat<br />
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen LuaCodeCache forever<br />
fb51a6b789d85113d0976148685b0063c294220drbowen LuaCodeCache never<br />
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic </code></p></div>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic</div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="directive-section"><h2><a name="LuaHookAccessChecker" id="LuaHookAccessChecker">LuaHookAccessChecker</a> <a name="luahookaccesschecker" id="luahookaccesschecker">Directive</a></h2>
fb51a6b789d85113d0976148685b0063c294220drbowen<table class="directive">
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the access_checker phase of request processing</td></tr>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookAccessChecker /path/to/lua/script.lua hook_function_name</code></td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
c994f52ac80f9664d2940e5ccd9e77466572013frbowen<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen</table>
fb51a6b789d85113d0976148685b0063c294220drbowen<p>Add your hook to the access_checker phase. An access checker
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowenhook function usually returns OK, DECLINED, or HTTP_FORBIDDEN.</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
249cc9b3d83d3c60666269b90ecb9f1390d32165poirier</div>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<div class="directive-section"><h2><a name="LuaHookAuthChecker" id="LuaHookAuthChecker">LuaHookAuthChecker</a> <a name="luahookauthchecker" id="luahookauthchecker">Directive</a></h2>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<table class="directive">
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the auth_checker phase of request processing</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookAuthChecker /path/to/lua/script.lua hook_function_name</code></td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen</table>
fb51a6b789d85113d0976148685b0063c294220drbowen<p>Invoke a lua function in the auth_checker phase of processing
fb51a6b789d85113d0976148685b0063c294220drbowena request. This can be used to implement arbitrary authentication
c994f52ac80f9664d2940e5ccd9e77466572013frbowenand authorization checking. A very simple example:
fb51a6b789d85113d0976148685b0063c294220drbowen</p>
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="example"><pre>
c994f52ac80f9664d2940e5ccd9e77466572013frbowenrequire 'apache2'
fb51a6b789d85113d0976148685b0063c294220drbowen
c994f52ac80f9664d2940e5ccd9e77466572013frbowen-- fake authcheck hook
c994f52ac80f9664d2940e5ccd9e77466572013frbowen-- If request has no auth info, set the response header and
c994f52ac80f9664d2940e5ccd9e77466572013frbowen-- return a 401 to ask the browser for basic auth info.
c994f52ac80f9664d2940e5ccd9e77466572013frbowen-- If request has auth info, don't actually look at it, just
c994f52ac80f9664d2940e5ccd9e77466572013frbowen-- pretend we got userid 'foo' and validated it.
c994f52ac80f9664d2940e5ccd9e77466572013frbowen-- Then check if the userid is 'foo' and accept the request.
c994f52ac80f9664d2940e5ccd9e77466572013frbowenfunction authcheck_hook(r)
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen -- look for auth info
fb51a6b789d85113d0976148685b0063c294220drbowen auth = r.headers_in['Authorization']
fb51a6b789d85113d0976148685b0063c294220drbowen if auth ~= nil then
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen -- fake the user
fb51a6b789d85113d0976148685b0063c294220drbowen r.user = 'foo'
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic end
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic if r.user == nil then
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic r:debug("authcheck: user is nil, returning 401")
fb51a6b789d85113d0976148685b0063c294220drbowen r.err_headers_out['WWW-Authenticate'] = 'Basic realm="WallyWorld"'
fb51a6b789d85113d0976148685b0063c294220drbowen return 401
fb51a6b789d85113d0976148685b0063c294220drbowen elseif r.user == "foo" then
fb51a6b789d85113d0976148685b0063c294220drbowen r:debug('user foo: OK')
fb51a6b789d85113d0976148685b0063c294220drbowen else
fb51a6b789d85113d0976148685b0063c294220drbowen r:debug("authcheck: user='" .. r.user .. "'")
fb51a6b789d85113d0976148685b0063c294220drbowen r.err_headers_out['WWW-Authenticate'] = 'Basic realm="WallyWorld"'
fb51a6b789d85113d0976148685b0063c294220drbowen return 401
fb51a6b789d85113d0976148685b0063c294220drbowen end
fb51a6b789d85113d0976148685b0063c294220drbowen return apache2.OK
fb51a6b789d85113d0976148685b0063c294220drbowenend
fb51a6b789d85113d0976148685b0063c294220drbowen</pre></div>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen</div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="directive-section"><h2><a name="LuaHookCheckUserID" id="LuaHookCheckUserID">LuaHookCheckUserID</a> <a name="luahookcheckuserid" id="luahookcheckuserid">Directive</a></h2>
fb51a6b789d85113d0976148685b0063c294220drbowen<table class="directive">
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the check_user_id phase of request processing</td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookCheckUserID /path/to/lua/script.lua hook_function_name</code></td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier</table><p>...</p>
92e5d4326ae44f79da5cb049470daba604506846poirier</div>
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="directive-section"><h2><a name="LuaHookFixups" id="LuaHookFixups">LuaHookFixups</a> <a name="luahookfixups" id="luahookfixups">Directive</a></h2>
92e5d4326ae44f79da5cb049470daba604506846poirier<table class="directive">
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the fixups phase of request
92e5d4326ae44f79da5cb049470daba604506846poirierprocessing</td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookFixups /path/to/lua/script.lua hook_function_name</code></td></tr>
92e5d4326ae44f79da5cb049470daba604506846poirier<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen</table>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen<p>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen Just like LuaHookTranslateName, but executed at the fixups phase
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic</div>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<div class="directive-section"><h2><a name="LuaHookInsertFilter" id="LuaHookInsertFilter">LuaHookInsertFilter</a> <a name="luahookinsertfilter" id="luahookinsertfilter">Directive</a></h2>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<table class="directive">
3e30fa5f420fe7302a4cdcd79cb001958fd54a13rbowen<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the insert_filter phase of request processing</td></tr>
3e30fa5f420fe7302a4cdcd79cb001958fd54a13rbowen<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookInsertFilter /path/to/lua/script.lua hook_function_name</code></td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
3e30fa5f420fe7302a4cdcd79cb001958fd54a13rbowen<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
3e30fa5f420fe7302a4cdcd79cb001958fd54a13rbowen<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen</table><p>Not Yet Implemented</p>
fb51a6b789d85113d0976148685b0063c294220drbowen</div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen<div class="directive-section"><h2><a name="LuaHookMapToStorage" id="LuaHookMapToStorage">LuaHookMapToStorage</a> <a name="luahookmaptostorage" id="luahookmaptostorage">Directive</a></h2>
fb51a6b789d85113d0976148685b0063c294220drbowen<table class="directive">
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the map_to_storage phase of request processing</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookMapToStorage /path/to/lua/script.lua hook_function_name</code></td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen</table><p>...</p>
fb51a6b789d85113d0976148685b0063c294220drbowen</div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen<div class="directive-section"><h2><a name="LuaHookTranslateName" id="LuaHookTranslateName">LuaHookTranslateName</a> <a name="luahooktranslatename" id="luahooktranslatename">Directive</a></h2>
fb51a6b789d85113d0976148685b0063c294220drbowen<table class="directive">
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the translate name phase of request processing</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookTranslateName /path/to/lua/script.lua hook_function_name</code></td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen</table><p>
fb51a6b789d85113d0976148685b0063c294220drbowen Add a hook (at APR_HOOK_MIDDLE) to the translate name phase of
fb51a6b789d85113d0976148685b0063c294220drbowen request processing. The hook function receives a single
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen argument, the request_rec, and should return a status code,
fb51a6b789d85113d0976148685b0063c294220drbowen which is either an HTTP error code, or the constants defined
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic in the apache2 module: apache2.OK, apache2.DECLINED, or
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic apache2.DONE. </p>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic <p>For those new to hooks, basically each hook will be invoked
fb51a6b789d85113d0976148685b0063c294220drbowen until one of them returns apache2.OK. If your hook doesn't
fb51a6b789d85113d0976148685b0063c294220drbowen want to do the translation it should just return
fb51a6b789d85113d0976148685b0063c294220drbowen apache2.DECLINED. If the request should stop processing, then
fb51a6b789d85113d0976148685b0063c294220drbowen return apache2.DONE.</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
9cd56c73a0fd508522ba2f6bc6c9839c478c61c3rbowen <p>Example:</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<div class="example"><pre>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic# httpd.conf
99e316bc4b9b2b5754165939ac14b6d16132cce1igalicLuaHookTranslateName /scripts/conf/hooks.lua silly_mapper
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier-- /scripts/conf/hooks.lua --
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirierrequire "apache2"
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirierfunction silly_mapper(r)
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier if r.uri == "/" then
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier r.filename = "/var/www/home.lua"
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier return apache2.OK
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier else
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier return apache2.DECLINED
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier end
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirierend
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier</pre></div>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier</div>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<div class="directive-section"><h2><a name="LuaHookTypeChecker" id="LuaHookTypeChecker">LuaHookTypeChecker</a> <a name="luahooktypechecker" id="luahooktypechecker">Directive</a></h2>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<table class="directive">
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the type_checker phase of request processing</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaHookTypeChecker /path/to/lua/script.lua hook_function_name</code></td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier</table><p>...</p>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier</div>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<div class="directive-section"><h2><a name="LuaMapHandler" id="LuaMapHandler">LuaMapHandler</a> <a name="luamaphandler" id="luamaphandler">Directive</a></h2>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<table class="directive">
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Map a path to a lua handler</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaMapHandler uri-pattern /path/to/lua/script.lua [function-name]</code></td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier</table>
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier <p>This directive matches a uri pattern to invoke a specific
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier handler function in a specific file. It uses PCRE regular
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier expressions to match the uri, and supports interpolating
768c8bcc0d91d1c3c04b0f80c309d31c6182fbf8poirier match groups into both the file path and the function name
fb51a6b789d85113d0976148685b0063c294220drbowen be careful writing your regular expressions to avoid security
fb51a6b789d85113d0976148685b0063c294220drbowen issues.</p>
fb51a6b789d85113d0976148685b0063c294220drbowen <div class="example"><h3>Examples:</h3><p><code>
fb51a6b789d85113d0976148685b0063c294220drbowen LuaMapHandler /(\w+)/(/w+) /scripts/$1.lua handle_$2
9cd56c73a0fd508522ba2f6bc6c9839c478c61c3rbowen </code></p></div>
fb51a6b789d85113d0976148685b0063c294220drbowen <p>This would match uri's such as /photos/show?id=9
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic to the file /scripts/photos.lua and invoke the
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic handler function handle_show on the lua vm after
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic loading that file.</p>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
92e5d4326ae44f79da5cb049470daba604506846poirier<div class="example"><p><code>
92e5d4326ae44f79da5cb049470daba604506846poirier LuaMapHandler /bingo /scripts/wombat.lua
92e5d4326ae44f79da5cb049470daba604506846poirier</code></p></div>
92e5d4326ae44f79da5cb049470daba604506846poirier <p>This would invoke the "handle" function, which
fb51a6b789d85113d0976148685b0063c294220drbowen is the default if no specific function name is
fb51a6b789d85113d0976148685b0063c294220drbowen provided.</p>
fb51a6b789d85113d0976148685b0063c294220drbowen
fb51a6b789d85113d0976148685b0063c294220drbowen</div>
9cd56c73a0fd508522ba2f6bc6c9839c478c61c3rbowen<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fb51a6b789d85113d0976148685b0063c294220drbowen<div class="directive-section"><h2><a name="LuaPackageCPath" id="LuaPackageCPath">LuaPackageCPath</a> <a name="luapackagecpath" id="luapackagecpath">Directive</a></h2>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<table class="directive">
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Add a directory to lua's package.cpath</td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaPackageCPath /path/to/include/?.soa</code></td></tr>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen</table>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen <p>Add a path to lua's shared library search path. Follows the same
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen conventions as lua. This just munges the package.cpath in the
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen lua vms.</p>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic</div>
99e316bc4b9b2b5754165939ac14b6d16132cce1igalic<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen<div class="directive-section"><h2><a name="LuaPackagePath" id="LuaPackagePath">LuaPackagePath</a> <a name="luapackagepath" id="luapackagepath">Directive</a></h2>
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen<table class="directive">
6b4cd1f143d5d7244d2476d1e28456212faddb72rbowen<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Add a directory to lua's package.path</td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaPackagePath /path/to/include/?.lua</code></td></tr>
fb51a6b789d85113d0976148685b0063c294220drbowen<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table><p>Add a path to lua's module search path. Follows the same
conventions as lua. This just munges the package.path in the
lua vms.</p>
<div class="example"><h3>Examples:</h3><p><code>
LuaPackagePath /scripts/lib/?.lua<br />
LuaPackagePath /scripts/lib/?/init.lua
</code></p></div>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="LuaQuickHandler" id="LuaQuickHandler">LuaQuickHandler</a> <a name="luaquickhandler" id="luaquickhandler">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Provide a hook for the quick handler of request processing</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code /></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table><p>...</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="LuaRoot" id="LuaRoot">LuaRoot</a> <a name="luaroot" id="luaroot">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Specify the base path for resolving relative paths for mod_lua directives</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaRoot /path/to/a/directory</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table>
<p>Specify the base path which will be used to evaluate all
relative paths within mod_lua. If not specified they
will be resolved relative to the current working directory,
which may not always work well for a server.</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="LuaScope" id="LuaScope">LuaScope</a> <a name="luascope" id="luascope">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>One of once, request, conn, server -- default is once</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LuaScope once|request|conn|server [max|min max]</code></td></tr>
<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LuaScope once</code></td></tr>
<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_lua</td></tr>
</table>
<p>Specify the lifecycle scope of the Lua interpreter which will
be used by handlers in this "Directory." The default is "once"</p>
<dl>
<dt>once:</dt> <dd>use the interpreter once and throw it away.</dd>
<dt>request:</dt> <dd>use the interpreter to handle anything based on
the same file within this request, which is also
request scoped.</dd>
<dt>conn:</dt> <dd>Same as request but attached to the connection_rec</dd>
<dt>server:</dt> <dd>This one is different than others because the
server scope is quite long lived, and multiple threads
will have the same server_rec. To accommodate this
server scoped interpreter are stored in an apr
resource list. The min and max arguments are intended
to specify the pool size, but are unused at this time.</dd>
</dl>
</div>
</div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="/en/mod/mod_lua.html" title="English">&nbsp;en&nbsp;</a></p>
</div><div id="footer">
<p class="apache">Copyright 2011 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>
</body></html>