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/bsw@16: if cgi then -- do nothing, when being in interactive mode jbe/bsw@16: local hash = {} jbe/bsw@16: for idx, slot_ident in ipairs(slot_idents) do jbe/bsw@16: hash[slot_ident] = true jbe/bsw@16: end jbe/bsw@16: if cgi.params["_webmcp_json_slots[]"] then jbe/bsw@16: for idx, slot_ident in ipairs(cgi.params["_webmcp_json_slots[]"]) do jbe/bsw@16: if not hash[slot_ident] then jbe/bsw@16: error('Requesting slot "' .. slot_ident .. '" is forbidden.') jbe/bsw@16: end jbe@1: end jbe@1: end jbe/bsw@16: request._json_requests_allowed = true jbe@1: end jbe@1: end