webmcp
view framework/env/request/get_json_request_slots.lua @ 88:c743d80859cf
Added tag v1.2.4 for changeset a5106c0a9be4
| author | jbe | 
|---|---|
| date | Fri Jul 06 12:54:26 2012 +0200 (2012-07-06) | 
| parents | 605488fbf809 | 
| children | 
 line source
     1 --[[--
     2 slot_idents =                    -- list of names of slots to be returned as JSON data
     3 request.get_json_request_slots()
     5 If the current request is no JSON request, this function returns nil, otherwise a list of names of all slots to be returned in JSON format. This function also throws an error, if JSON data was requested, but request.set_allowed_json_request_slots(...) has not been called.
     7 --]]--
     9 function request.get_json_request_slots(slot_idents)
    10   if not cgi then return end
    11   local slot_idents = cgi.params["_webmcp_json_slots[]"]
    12   if slot_idents and not request._json_requests_allowed then
    13     error("JSON requests have not been allowed using request.set_allowed_json_request_slots(...).")
    14   end
    15   return slot_idents
    16 end
