jbe/bsw@0: --[[-- jbe/bsw@0: value = -- value of the parameter casted to the chosen param_type jbe/bsw@0: param.get( jbe/bsw@0: key, -- name of the parameter jbe/bsw@0: param_type -- desired type of the returned value jbe/bsw@0: ) jbe/bsw@0: jbe/bsw@0: Either a GET or POST request parameter is returned by this function, or if param.exchange(...) was called before, one of the exchanged parameters is returned. You can specify which type the returned value shall have. If an external request parameter was used and there is another GET or POST parameter with the same name but a "__format" suffix, the parser with the name of the specified format will be automatically used to parse and convert the input value. jbe/bsw@0: jbe/bsw@0: --]]-- jbe/bsw@0: jbe/bsw@0: function param.get(key, param_type) jbe/bsw@0: local param_type = param_type or atom.string jbe/bsw@0: if param._exchanged then jbe/bsw@0: local value = param._exchanged.params[key] jbe/bsw@0: if value ~= nil and not atom.has_type(value, param_type) then jbe/bsw@0: error("Parameter has unexpected type.") jbe/bsw@0: end jbe/bsw@0: return value jbe/bsw@0: else jbe@223: local str = request.get_param{ name = key } jbe@223: local format_info = request.get_param{ name = key .. "__format" } jbe/bsw@0: if not str then jbe/bsw@0: if not format_info then jbe/bsw@0: return nil jbe/bsw@0: end jbe/bsw@0: str = "" jbe/bsw@0: end jbe/bsw@0: return param._get_parser(format_info, param_type)(str) jbe/bsw@0: end jbe/bsw@0: end