webmcp
diff framework/env/request/get_param_strings.lua @ 221:25a20bd1f416
More work on Moonbridge integration: several changes in env/request
| author | jbe |
|---|---|
| date | Wed Feb 25 01:33:27 2015 +0100 (2015-02-25) |
| parents | e75abc61d135 |
| children | 38e5399718ca |
line diff
1.1 --- a/framework/env/request/get_param_strings.lua Sun Feb 22 17:16:13 2015 +0100 1.2 +++ b/framework/env/request/get_param_strings.lua Wed Feb 25 01:33:27 2015 +0100 1.3 @@ -1,19 +1,26 @@ 1.4 --[[-- 1.5 params = 1.6 -param.get_param_strings() 1.7 +request.get_param_strings() 1.8 1.9 This function returns a table with all raw GET/POST parameters as strings or list of strings (except internal parameters like "_webmcp_path" or "_webmcp_id"). Modifications of the returned table have no side effects. 1.10 1.11 --]]-- 1.12 1.13 +local function merge_params(tbl, params_list) 1.14 + for key, values in pairs(tbl) do 1.15 + if string.match(key, "^_webmcp_") then 1.16 + -- do nothing 1.17 + elseif string.match(key, "%[%]$") then 1.18 + tbl[key] = table.new(values) 1.19 + else 1.20 + tbl[key] = values[1] 1.21 + end 1.22 + end 1.23 +end 1.24 + 1.25 function request.get_param_strings() 1.26 local t = {} 1.27 - for key, value in pairs(request._params) do 1.28 - if type(value) == 'table' then 1.29 - t[key] = table.new(value) 1.30 - else 1.31 - t[key] = value 1.32 - end 1.33 - end 1.34 + merge_params(t, request._http_request.get_params_list) 1.35 + merge_params(t, request._http_request.post_params_list) 1.36 return t 1.37 end