Make use of the features in falcon 0.1.3 & 0.1.4
* To build the query strings; * to build content_location; * and to ensure the type of the HTTP parameters. Implements: blueprint transport-wsgi Change-Id: Ibc06d68e43313e842854f08a8bff010624e7516c
This commit is contained in:
parent
2157af264c
commit
1a15292cf2
@ -30,7 +30,3 @@ def read_json(stream):
|
||||
|
||||
def to_json(o):
|
||||
return json.dumps(o, ensure_ascii=False)
|
||||
|
||||
|
||||
def join_params(d):
|
||||
return '&'.join([k + '=' + str(v).lower() for k, v in d.items()])
|
||||
|
@ -31,7 +31,7 @@ class CollectionResource(object):
|
||||
raise falcon.HTTPBadRequest(_('Bad request'),
|
||||
_('Missing claim metadata.'))
|
||||
|
||||
#TODO(zyuan): use falcon's new api to check these
|
||||
#TODO(zyuan): where do we define the limits?
|
||||
kwargs = {
|
||||
'limit': req.get_param_as_int('limit'),
|
||||
}
|
||||
@ -72,7 +72,7 @@ class ItemResource(object):
|
||||
tenant=tenant_id)
|
||||
|
||||
meta['messages'] = list(msgs)
|
||||
resp.content_location = req.path
|
||||
resp.content_location = req.relative_uri
|
||||
resp.body = helpers.to_json(meta)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
@ -66,12 +66,11 @@ class CollectionResource(object):
|
||||
def on_get(self, req, resp, tenant_id, queue_name):
|
||||
uuid = req.get_header('Client-ID', required=True)
|
||||
|
||||
#TODO(zyuan): use falcon's new api to check these
|
||||
#TODO(zyuan): where do we define the limits?
|
||||
kwargs = {
|
||||
'marker': req.get_param('marker'),
|
||||
'limit': req.get_param_as_int('limit'),
|
||||
'echo': {'true': True,
|
||||
'false': False}.get(req.get_param('echo'))
|
||||
'echo': req.get_param_as_bool('echo'),
|
||||
}
|
||||
kwargs = dict([(k, v) for k, v in kwargs.items()
|
||||
if v is not None])
|
||||
@ -96,11 +95,11 @@ class CollectionResource(object):
|
||||
resp_dict['links'] = [
|
||||
{
|
||||
'rel': 'next',
|
||||
'href': req.path + '?' + helpers.join_params(kwargs)
|
||||
'href': req.path + falcon.to_query_str(kwargs)
|
||||
}
|
||||
]
|
||||
|
||||
resp.content_location = req.path + '?' + req.query_string
|
||||
resp.content_location = req.relative_uri
|
||||
resp.body = helpers.to_json(resp_dict)
|
||||
resp.status = falcon.HTTP_200
|
||||
else:
|
||||
@ -120,7 +119,7 @@ class ItemResource(object):
|
||||
message_id=message_id,
|
||||
tenant=tenant_id)
|
||||
|
||||
resp.content_location = req.path
|
||||
resp.content_location = req.relative_uri
|
||||
resp.body = helpers.to_json(msg)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
@ -73,7 +73,7 @@ class ItemResource(object):
|
||||
raise falcon.HTTPServiceUnavailable(title, msg, 30)
|
||||
|
||||
try:
|
||||
resp.content_location = req.path
|
||||
resp.content_location = req.relative_uri
|
||||
resp.body = helpers.to_json(doc)
|
||||
except TypeError as ex:
|
||||
LOG.error(ex)
|
||||
@ -103,7 +103,7 @@ class CollectionResource(object):
|
||||
|
||||
resp_dict['queues'] = list(queues)
|
||||
|
||||
resp.content_location = req.path
|
||||
resp.content_location = req.relative_uri
|
||||
resp.body = helpers.to_json(resp_dict)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
cliff
|
||||
falcon
|
||||
falcon>=0.1.4
|
||||
msgpack-python
|
||||
oslo.config>=1.1.0
|
||||
PasteDeploy
|
||||
|
Loading…
x
Reference in New Issue
Block a user