jbe@1: --[[-- jbe@1: request.set_allowed_json_request_slots( jbe@1: slot_idents -- list of names of slots which can be requested in JSON format jbe@1: ) jbe@1: jbe@1: This function enables JSON requests. The given list of names of slots selects, which slots may be requestd in JSON format (without layout). jbe@1: jbe@1: --]]-- jbe@1: jbe@1: function request.set_allowed_json_request_slots(slot_idents) jbe@1: local hash = {} jbe@1: for idx, slot_ident in ipairs(slot_idents) do jbe@1: hash[slot_ident] = true jbe@1: end jbe@1: if cgi.params["_webmcp_json_slots[]"] then jbe@1: for idx, slot_ident in ipairs(cgi.params["_webmcp_json_slots[]"]) do jbe@1: if not hash[slot_ident] then jbe@1: error('Requesting slot "' .. slot_ident .. '" is forbidden.') jbe@1: end jbe@1: end jbe@1: end jbe@1: request._json_requests_allowed = true jbe@1: end