示例#1
0
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)
示例#2
0
 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))
示例#3
0
    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")
        )
示例#4
0
 def on_post(self, req, resp):
     args = {
         "name": fields.Nested({
             "first": fields.Str(),
             "last": fields.Str()
         })
     }
     resp.body = json.dumps(parser.parse(args, req))
示例#5
0
 def on_post(self, req, resp):
     args = {
         'name': fields.Nested({
             'first': fields.Str(),
             'last': fields.Str()
         })
     }
     resp.body = json.dumps(parser.parse(args, req))
示例#6
0
 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)
示例#7
0
    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))
示例#8
0
 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))
示例#9
0
 def on_put(self, req, resp):
     args = parser.parse(hello_args, req=req, locations=('json', ))
     resp.body = json.dumps(args)
示例#10
0
 def on_get(self, req, resp):
     resp.body = json.dumps(parser.parse(hello_args, req, locations=("cookies",)))
示例#11
0
 def hook(req, resp, params):
     req.context["args"] = parser.parse(argmap, req=req, **kwargs)
示例#12
0
 def on_post(self, req, resp):
     resp.body = json.dumps(parser.parse(hello_many_schema, req))
示例#13
0
 def on_post(self, req, resp):
     resp.body = json.dumps(
         parser.parse(hello_multiple, req, location="form"))
示例#14
0
 def on_get(self, req, resp):
     parsed = parser.parse(hello_args, req, locations=("query",))
     resp.body = json.dumps(parsed)
示例#15
0
 def on_get(self, req, resp):
     resp.body = json.dumps(
         parser.parse(hello_many_schema, req, locations=("json",))
     )
示例#16
0
 def on_get(self, req, resp):
     parsed = parser.parse(hello_args, req)
     resp.body = json.dumps(parsed)
示例#17
0
 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))
示例#18
0
 def on_get(self, req, resp):
     resp.body = json.dumps(parser.parse(hello_args, req, locations=('headers', )))
示例#19
0
 def hook(req, resp, params):
     parsed_args = parser.parse(args, req=req, **kwargs)
     req.context[context_key] = parsed_args
示例#20
0
 def on_get(self, req, resp):
     args = parser.parse(hello_args,
                         req=req,
                         locations=('query', 'headers', 'cookies'))
     resp.body = json.dumps(args)
示例#21
0
 def on_get(self, req, resp):
     resp.body = json.dumps(
         parser.parse(hello_multiple, req, location="query"))
示例#22
0
 def on_get(self, req, resp):
     resp.body = json.dumps(parser.parse(hello_multiple, req))
示例#23
0
 def on_get(self, req, resp):
     parser.parse(self.args, req=req)
示例#24
0
    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))
示例#25
0
 def on_post(self, req, resp):
     parsed = parser.parse(hello_args, req, location="json_or_form")
     resp.body = json.dumps(parsed)