annotate framework/env/request/get_json_request_slots.lua @ 194:654ddbcc49d0
Bugfix in autodoc.lua; Added documentation for JSON library; json.import(...) returns json.null for "null" on top-level
 | author | 
 jbe | 
 | date | 
 Mon Aug 11 17:38:12 2014 +0200 (2014-08-11) | 
 | parents | 
 605488fbf809  | 
 | children | 
  | 
 
 | rev | 
   line source | 
| 
jbe@1
 | 
     1 --[[--
 | 
| 
jbe@1
 | 
     2 slot_idents =                    -- list of names of slots to be returned as JSON data
 | 
| 
jbe@1
 | 
     3 request.get_json_request_slots()
 | 
| 
jbe@1
 | 
     4 
 | 
| 
jbe@1
 | 
     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.
 | 
| 
jbe@1
 | 
     6 
 | 
| 
jbe@1
 | 
     7 --]]--
 | 
| 
jbe@1
 | 
     8 
 | 
| 
jbe@1
 | 
     9 function request.get_json_request_slots(slot_idents)
 | 
| 
bsw@24
 | 
    10   if not cgi then return end
 | 
| 
jbe@1
 | 
    11   local slot_idents = cgi.params["_webmcp_json_slots[]"]
 | 
| 
jbe@1
 | 
    12   if slot_idents and not request._json_requests_allowed then
 | 
| 
jbe@1
 | 
    13     error("JSON requests have not been allowed using request.set_allowed_json_request_slots(...).")
 | 
| 
jbe@1
 | 
    14   end
 | 
| 
jbe@1
 | 
    15   return slot_idents
 | 
| 
jbe@1
 | 
    16 end
 |