blob: 0d56ab9f2aa552eec32ced2b081193ba4d04baf4 [file] [log] [blame]
require "string"
--[[
This is the default method name for Lua handlers, see the optional
function-name in the LuaMapHandler directive to choose a different
entry point.
--]]
function handle(r)
r.content_type = "text/plain"
if r.method == 'GET' then
r:puts("Hello Lua World, got your GET!\n")
r.headers_out["Cache-Control"] = 'Private'
for k, v in pairs( r:parseargs() ) do
r:puts( string.format("%s: %s\n", k, v) )
end
elseif r.method == 'POST' then
r:puts("Hello Lua World, got your POST!\n")
for k, v in pairs( r:parsebody() ) do
r:puts( string.format("%s: %s\n", k, v) )
end
elseif r.method == 'PUT' then
-- use our own Error contents
r:puts("Unsupported HTTP method " .. r.method)
r.status = 405
return apache2.OK
else
-- use the ErrorDocument
return 501
end
return apache2.OK
end