From: Daniel Gruno mod_status.
just evaluating a script body CGI style. A handler function looks
something like this:
+
+
+example.lua
-- example handler
require "string"
@@ -144,7 +146,8 @@ function handle(r)
r:puts("unknown HTTP method " .. r.method)
end
end
-
This handler function just prints out the uri or form encoded
@@ -172,7 +175,8 @@ they'll return OK, DONE, or DECLINED, which you can write in lua as
apache2.OK, apache2.DONE, or
apache2.DECLINED, or else an HTTP status code.
+
+translate_name.lua
-- example hook that rewrites the URI to a filesystem path.
require 'apache2'
@@ -185,9 +189,11 @@ function translate_name(r)
-- we don't care about this URL, give another module a chance
return apache2.DECLINED
end
-
+
+
+translate_name2.lua
--[[ example hook that rewrites one URI to another URI. It returns a
apache2.DECLINED to give other URL mappers a chance to work on the
substitution, including the core translate_name hook which maps based
@@ -206,7 +212,8 @@ function translate_name(r)
end
return apache2.DECLINED
end
-
+
-- examples of logging messages
r:trace1("This is a trace log message") -- trace1 through trace8 can be used
r:debug("This is a debug log message")
@@ -399,7 +406,8 @@ end
r:alert("This is an alert log message")
r:crit("This is an crit log message")
r:emerg("This is an emerg log message")
-
+
require 'apache2'
-- fake authcheck hook
@@ -516,7 +524,8 @@ function authcheck_hook(r)
end
return apache2.OK
end
-The optional arguments "early" or "late" control when this script runs relative to other modules.
# httpd.conf LuaHookTranslateName /scripts/conf/hooks.lua silly_mapper +
-- /scripts/conf/hooks.lua --
require "apache2"
function silly_mapper(r)
@@ -614,7 +625,8 @@ function silly_mapper(r)
return apache2.DECLINED
end
end
-This directive is not valid in <Directory>, <Files>, or htaccess
context.
+ ++example.lua -- example handler require "string" @@ -112,7 +114,7 @@ function handle(r) r:puts("unknown HTTP method " .. r.method) end end -
This handler function just prints out the uri or form encoded
@@ -140,7 +142,8 @@ they'll return OK, DONE, or DECLINED, which you can write in lua as
apache2.OK, apache2.DONE, or
apache2.DECLINED, or else an HTTP status code.
++translate_name.lua -- example hook that rewrites the URI to a filesystem path. require 'apache2' @@ -153,9 +156,10 @@ function translate_name(r) -- we don't care about this URL, give another module a chance return apache2.DECLINED end -
++translate_name2.lua --[[ example hook that rewrites one URI to another URI. It returns a apache2.DECLINED to give other URL mappers a chance to work on the substitution, including the core translate_name hook which maps based @@ -174,7 +178,7 @@ function translate_name(r) end return apache2.DECLINED end -
# httpd.conf LuaHookTranslateName /scripts/conf/hooks.lua silly_mapper +
This directive is not valid in
+require 'apache2' -- fake authcheck hook @@ -692,7 +698,7 @@ function authcheck_hook(r) end return apache2.OK end -
The optional arguments "early" or "late" control when this script runs relative to other modules.