webmcp
view framework/env/request/set_status.lua @ 31:1cd9e69b85cb
add execute.load_chunk(args)
load_chunk loads the content of a lua file and returns the code.
It can construct the path name easily so you can put helper code in
seperate files for DRYness.
load_chunk loads the content of a lua file and returns the code.
It can construct the path name easily so you can put helper code in
seperate files for DRYness.
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Tue Oct 05 02:34:04 2010 +0200 (2010-10-05) | 
| parents | 9fdfb27f8e67 | 
| children | 
 line source
     1 --[[--
     2 request.set_status(
     3   str                -- string containing a HTTP status code, e.g. "404 Not Found"
     4 )
     6 Calling this function causes a HTTP status different from 200 OK (or in case of error different from 500 Internal Server Error) to be sent to the browser.
     8 --]]--
    10 function request.set_status(str)
    11   if str then
    12     local t = type(str)
    13     if type(str) == "number" then
    14       str = tostring(str)
    15     elseif type(str) ~= "string" then
    16       error("request.set_status(...) must be called with a string as parameter.")
    17     end
    18     request._status = str
    19   else
    20     request._status = nil
    21   end
    22 end
