webmcp

annotate framework/env/request/set_allowed_json_request_slots.lua @ 218:15c9de7832cc

Removed unnecessary extra slash in autoloader in mcp.lua
author jbe
date Sun Feb 22 13:03:34 2015 +0100 (2015-02-22)
parents 944642a3e488
children
rev   line source
jbe@1 1 --[[--
jbe@1 2 request.set_allowed_json_request_slots(
jbe@1 3 slot_idents -- list of names of slots which can be requested in JSON format
jbe@1 4 )
jbe@1 5
jbe@1 6 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 7
jbe@1 8 --]]--
jbe@1 9
jbe@1 10 function request.set_allowed_json_request_slots(slot_idents)
jbe/bsw@16 11 if cgi then -- do nothing, when being in interactive mode
jbe/bsw@16 12 local hash = {}
jbe/bsw@16 13 for idx, slot_ident in ipairs(slot_idents) do
jbe/bsw@16 14 hash[slot_ident] = true
jbe/bsw@16 15 end
jbe/bsw@16 16 if cgi.params["_webmcp_json_slots[]"] then
jbe/bsw@16 17 for idx, slot_ident in ipairs(cgi.params["_webmcp_json_slots[]"]) do
jbe/bsw@16 18 if not hash[slot_ident] then
jbe/bsw@16 19 error('Requesting slot "' .. slot_ident .. '" is forbidden.')
jbe/bsw@16 20 end
jbe@1 21 end
jbe@1 22 end
jbe/bsw@16 23 request._json_requests_allowed = true
jbe@1 24 end
jbe@1 25 end

Impressum / About Us