Merge "Rename zone > domain for errors in V1"
This commit is contained in:
commit
e2061af49c
@ -272,6 +272,9 @@ class FaultWrapperMiddleware(base.Middleware):
|
||||
# Handle all other exception types
|
||||
return self._handle_exception(request, e)
|
||||
|
||||
def _format_error(self, data):
|
||||
pass
|
||||
|
||||
def _handle_exception(self, request, e, status=500, response=None):
|
||||
|
||||
response = response or {}
|
||||
@ -292,6 +295,8 @@ class FaultWrapperMiddleware(base.Middleware):
|
||||
if 'type' not in response:
|
||||
response['type'] = 'unknown'
|
||||
|
||||
self._format_error(response)
|
||||
|
||||
# Return the new response
|
||||
if 'context' in request.environ:
|
||||
response['request_id'] = request.environ['context'].request_id
|
||||
@ -307,6 +312,17 @@ class FaultWrapperMiddleware(base.Middleware):
|
||||
response=json.dumps(response))
|
||||
|
||||
|
||||
class FaultWrapperMiddlewareV1(FaultWrapperMiddleware):
|
||||
def _format_error(self, data):
|
||||
replace_map = [
|
||||
("zone", "domain",)
|
||||
]
|
||||
|
||||
for i in replace_map:
|
||||
data["type"] = data["type"].replace(i[0], i[1])
|
||||
print(data)
|
||||
|
||||
|
||||
class ValidationErrorMiddleware(base.Middleware):
|
||||
|
||||
def __init__(self, application):
|
||||
|
@ -15,8 +15,8 @@ paste.app_factory = designate.api.versions:factory
|
||||
|
||||
[composite:osapi_dns_v1]
|
||||
use = call:designate.api.middleware:auth_pipeline_factory
|
||||
noauth = http_proxy_to_wsgi cors request_id noauthcontext maintenance validation_API_v1 faultwrapper normalizeuri osapi_dns_app_v1
|
||||
keystone = http_proxy_to_wsgi cors request_id authtoken keystonecontext maintenance validation_API_v1 faultwrapper normalizeuri osapi_dns_app_v1
|
||||
noauth = http_proxy_to_wsgi cors request_id noauthcontext maintenance validation_API_v1 faultwrapper_v1 normalizeuri osapi_dns_app_v1
|
||||
keystone = http_proxy_to_wsgi cors request_id authtoken keystonecontext maintenance validation_API_v1 faultwrapper_v1 normalizeuri osapi_dns_app_v1
|
||||
|
||||
|
||||
[app:osapi_dns_app_v1]
|
||||
@ -66,6 +66,9 @@ paste.filter_factory = designate.api.middleware:NormalizeURIMiddleware.factory
|
||||
[filter:faultwrapper]
|
||||
paste.filter_factory = designate.api.middleware:FaultWrapperMiddleware.factory
|
||||
|
||||
[filter:faultwrapper_v1]
|
||||
paste.filter_factory = designate.api.middleware:FaultWrapperMiddlewareV1.factory
|
||||
|
||||
[filter:validation_API_v1]
|
||||
paste.filter_factory = designate.api.middleware:APIv1ValidationErrorMiddleware.factory
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user