From af893df5fa407fd7c85fa4e727f7ff22356fd806 Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Fri, 5 Aug 2011 15:52:33 +0000 Subject: [PATCH] explain some of the mystery quirks of the translate_name example, and introduce one that does a more basic URI->filename. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1154277 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/mod/mod_lua.xml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/manual/mod/mod_lua.xml b/docs/manual/mod/mod_lua.xml index 2488d1289d..e9de427784 100644 --- a/docs/manual/mod/mod_lua.xml +++ b/docs/manual/mod/mod_lua.xml @@ -140,7 +140,29 @@ they'll return OK, DONE, or DECLINED, which you can write in lua as apache2.DECLINED, or else an HTTP status code.

translate_name.lua
--- example hook
+-- example hook that rewrites the URI to a filesystem path.
+
+require 'apache2'
+
+function translate_name(r)
+    if r.uri == "/translate-name" then
+        r.filename = r.document_root .. "/find_me.txt"
+        return apache2.OK
+    end
+    -- 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
+     on the DocumentRoot.  
+
+     Note: It is currently undefined as to whether this runs before or after
+     mod_alias or any other module implementing the same hook.
+--]]
 
 require 'apache2'
 
-- 
2.50.0