def wapper(self): try: self.json_obj = json.loads(self.request.body) fuc(self) except Exception, e: fd_log.error("json decode error:%s,http body:%s", e, self.request.body)
def httpJSONArgsCheck(json_str, required_args, optional_args): for arg in required_args: if arg not in json_str: fd_log.error("Http JSON protocol is lack of required argument: %s!", arg) return False for arg in optional_args: if arg not in json_str: json_str[arg] = None # fd_log.warn("Http JSON protocol is lack of optional argument: %s.", arg) return True
def wapper(self): flag = True for argument in arguments: if argument not in self.json_obj: flag = False break if flag: fuc(self) else: fd_log.error("lack of arguments error") self.write("lack of arguments error")
def httpJSONArgsCheck(json_str, required_args, optional_args): for arg in required_args: if arg not in json_str: fd_log.error( "Http JSON protocol is lack of required argument: %s!", arg) return False for arg in optional_args: if arg not in json_str: json_str[arg] = None # fd_log.warn("Http JSON protocol is lack of optional argument: %s.", arg) return True