REST API / (versions) endpoint has been fixed.

Change-Id: I987ec98c562bccdc5680d60bb8ea00e0023921e6
This commit is contained in:
Sergey Lukjanov
2013-06-13 14:51:05 +04:00
parent 4c30409ac7
commit a292ba8ae8
2 changed files with 14 additions and 12 deletions

View File

@@ -80,9 +80,10 @@ def make_app():
@app.teardown_request
def teardown_request(_ex=None):
# TODO(slukjanov): how it'll work in case of exception?
session = context.session()
if session.transaction:
session.transaction.commit()
if flask.request.path != '/':
session = context.session()
if session.transaction:
session.transaction.commit()
app.register_blueprint(api_v10.rest, url_prefix='/v1.0')

View File

@@ -45,17 +45,18 @@ class AuthValidator:
return resp(env, start_response)
path = env['PATH_INFO']
version, url_tenant, rest = commons.split_path(path, 3, 3, True)
if path != '/':
version, url_tenant, rest = commons.split_path(path, 3, 3, True)
if not version or not url_tenant or not rest:
LOG.info("Incorrect path: %s", path)
resp = ex.HTTPNotFound("Incorrect path")
resp(env, start_response)
if not version or not url_tenant or not rest:
LOG.info("Incorrect path: %s", path)
resp = ex.HTTPNotFound("Incorrect path")
resp(env, start_response)
if token_tenant != url_tenant:
LOG.debug("Unauthorized: token tenant != requested tenant")
resp = ex.HTTPUnauthorized('Token tenant != requested tenant')
return resp(env, start_response)
if token_tenant != url_tenant:
LOG.debug("Unauthorized: token tenant != requested tenant")
resp = ex.HTTPUnauthorized('Token tenant != requested tenant')
return resp(env, start_response)
return self.app(env, start_response)