1 mod_wombat always looks to invoke a function for the handler, rather than
2 just evaluating a script body CGI style. A handler function looks
8 function handle_something(r)
9 r.content_type = "text/plain"
10 r:puts("Hello Lua World!\n")
12 if r.method == 'GET' then
13 for k, v in pairs( r:parseargs() ) do
14 r:puts( string.format("%s: %s", k, v) )
16 elseif r.method == 'POST' then
17 for k, v in pairs( r:parsebody() ) do
18 r:puts( string.format("%s: %s", k, v) )
21 r:puts("unknown HTTP method " .. r.method)
25 This handler function just prints out the uri or form encoded
26 arguments to a plaintext page.
28 This means (and in fact encourages) that you can have multiple
29 handlers (or hooks, or filters) in the same script.
33 the request_rec is mapped in as a userdata. It has a metatable
34 which lets you do useful things with it. For the most part it
35 has the same fields as the request_rec struct (see httpd.h
36 until we get better docs here) many of which are writeable as
37 well as readable, and has (at least) the following methods:
39 r:puts("hello", " world", "!") -- print to response body
42 r:debug("This is a debug log message")
43 r:info("This is an info log message")
44 r:notice("This is an notice log message")
45 r:warn("This is an warn log message")
46 r:err("This is an err log message")
47 r:alert("This is an alert log message")
48 r:crit("This is an crit log message")
49 r:emerg("This is an emerg log message")