webmcp

view framework/env/request/get_param_strings.lua @ 569:5b19007574de

New argument active_link_attr for env.ui.paginate{...}
author jbe
date Wed Oct 13 17:21:44 2021 +0200 (13 months ago)
parents ffdd32b48296
children
line source
1 --[[--
2 params =
3 request.get_param_strings{
4 method = method, -- "GET", "POST", or nil to query both (POST has precedence)
5 include_internal = include_internal -- set to true to include also parameters starting with "_webmcp_" prefix
6 }
8 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.
10 --]]--
12 local function merge_params(tbl, params_list, include)
13 for key, values in pairs(params_list) do
14 if not include and string.match(key, "^_webmcp_") then
15 -- do nothing
16 elseif string.match(key, "%[%]$") then
17 tbl[key] = table.new(values)
18 else
19 tbl[key] = values[1]
20 end
21 end
22 end
24 function request.get_param_strings(args)
25 local method = nil
26 local include = false
27 if args then
28 method = args.method
29 include = args.include_internal
30 end
31 local t = {}
32 if not method then
33 merge_params(t, request._http_request.get_params_list, include)
34 merge_params(t, request._http_request.post_params_list, include)
35 elseif method == "GET" then
36 merge_params(t, request._http_request.get_params_list, include)
37 elseif method == "POST" then
38 merge_params(t, request._http_request.post_params_list, include)
39 else
40 error("Invalid method passed to request.get_param_strings{...}")
41 end
42 return t
43 end

Impressum / About Us