def before_get_it(req, resp, name): log = JLog().bind() try: parsed_args = parser.parse(hello_args, req=req) except HTTPError as e: log.error_trace(str(e.errors)) raise Exception(e.errors)
def on_post(self, req, resp): args = { "users": fields.Nested( {"id": fields.Int(), "name": fields.Str()}, many=True ) } resp.body = json.dumps(parser.parse(args, req))
def on_get(self, req, resp): class HeaderSchema(ma.Schema): NAME = fields.Str(missing="World") resp.body = json.dumps( parser.parse(HeaderSchema(**exclude_kwargs), req, location="headers") )
def on_post(self, req, resp): args = { "name": fields.Nested({ "first": fields.Str(), "last": fields.Str() }) } resp.body = json.dumps(parser.parse(args, req))
def on_post(self, req, resp): args = { 'name': fields.Nested({ 'first': fields.Str(), 'last': fields.Str() }) } resp.body = json.dumps(parser.parse(args, req))
def on_get(self, req, resp): try: parsed = parser.parse(hello_args, req) except json.JSONDecodeError: resp.body = json.dumps(["Invalid JSON."]) resp.status = falcon.HTTP_400 else: resp.body = json.dumps(parsed)
def parse(self, request, supported_args): self._req = request try: self._json = json.load(self._req.bounded_stream) except: self._json = {} self._parsed_args = ObjectDict( **req_parser.parse(supported_args, self._req))
def on_post(self, req, resp): args = { 'users': fields.Nested({ 'id': fields.Int(), 'name': fields.Str() }, many=True) } resp.body = json.dumps(parser.parse(args, req))
def on_put(self, req, resp): args = parser.parse(hello_args, req=req, locations=('json', )) resp.body = json.dumps(args)
def on_get(self, req, resp): resp.body = json.dumps(parser.parse(hello_args, req, locations=("cookies",)))
def hook(req, resp, params): req.context["args"] = parser.parse(argmap, req=req, **kwargs)
def on_post(self, req, resp): resp.body = json.dumps(parser.parse(hello_many_schema, req))
def on_post(self, req, resp): resp.body = json.dumps( parser.parse(hello_multiple, req, location="form"))
def on_get(self, req, resp): parsed = parser.parse(hello_args, req, locations=("query",)) resp.body = json.dumps(parsed)
def on_get(self, req, resp): resp.body = json.dumps( parser.parse(hello_many_schema, req, locations=("json",)) )
def on_get(self, req, resp): parsed = parser.parse(hello_args, req) resp.body = json.dumps(parsed)
def on_get(self, req, resp): def always_fail(value): raise ValidationError('something went wrong', status_code=12345) args = {'text': fields.Str(validate=always_fail)} resp.body = json.dumps(parser.parse(args, req))
def on_get(self, req, resp): resp.body = json.dumps(parser.parse(hello_args, req, locations=('headers', )))
def hook(req, resp, params): parsed_args = parser.parse(args, req=req, **kwargs) req.context[context_key] = parsed_args
def on_get(self, req, resp): args = parser.parse(hello_args, req=req, locations=('query', 'headers', 'cookies')) resp.body = json.dumps(args)
def on_get(self, req, resp): resp.body = json.dumps( parser.parse(hello_multiple, req, location="query"))
def on_get(self, req, resp): resp.body = json.dumps(parser.parse(hello_multiple, req))
def on_get(self, req, resp): parser.parse(self.args, req=req)
def on_get(self, req, resp): def always_fail(value): raise ma.ValidationError("something went wrong") args = {"text": fields.Str(validate=always_fail)} resp.body = json.dumps(parser.parse(args, req))
def on_post(self, req, resp): parsed = parser.parse(hello_args, req, location="json_or_form") resp.body = json.dumps(parsed)