webmcp

view framework/env/request/get_param.lua @ 270:aedd13009ddc

Proper handling of 404's and mime types for static file delivery
author jbe
date Fri Mar 20 16:38:37 2015 +0100 (2015-03-20)
parents 6ac7133bb58e
children 264af2867720
line source
1 --[[--
2 value = -- value of GET/POST parameter, or value list if multiple == true
3 request.get_param{
4 method = method, -- "GET", "POST", or nil to query both (POST has precedence)
5 name = name, -- field name
6 index = index, -- defaults to 1 to get first occurrence, only applicable if multiple == false
7 multiple = multiple -- boolean to indicate whether to return a single value or a value list
8 }
10 Reads GET/POST parameters directly from the underlaying request.
12 --]]--
14 function request.get_param(args)
15 local param_list
16 if args.method == "GET" then
17 param_list = request._http_request.get_params_list[args.name]
18 elseif args.method == "POST" then
19 param_list = request._http_request.post_params_list[args.name]
20 elseif not args.method then
21 param_list = request._http_request.post_params_list[args.name]
22 if not param_list[index or 1] then
23 param_list = request._http_request.get_params_list[args.name]
24 end
25 end
26 if multiple then
27 return param_list
28 else
29 return param_list[index or 1]
30 end
31 end
33 --//--

Impressum / About Us