diff options
author | Michael Krotscheck <krotscheck@gmail.com> | 2015-06-11 11:49:51 -0700 |
---|---|---|
committer | Michael Krotscheck <krotscheck@gmail.com> | 2015-06-16 15:19:18 -0700 |
commit | afb79f98cfe817e25661fda3b36685e34c8e9543 (patch) | |
tree | df719a59b724ad5edc6e55f6a4d6fcb86321e0af | |
parent | ecdb1b06c4638fab9816f0dd2278c939d14f5886 (diff) | |
download | oslo-middleware-afb79f98cfe817e25661fda3b36685e34c8e9543.tar.gz |
Use correct oslo_middleware.base methods in CORS middleware.
This patch modifies the CORS middleware to use the __call__ logic
from its parent class, rather than overriding it. Logic has been
moved into process_request and process_response accordingly.
Change-Id: Ia5907ec37c1103a9b9a24d549a81822b1b3ad332
-rw-r--r-- | oslo_middleware/cors.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/oslo_middleware/cors.py b/oslo_middleware/cors.py index 3e0021b..513bdbc 100644 --- a/oslo_middleware/cors.py +++ b/oslo_middleware/cors.py @@ -15,6 +15,7 @@ # Default allowed headers import copy import logging + from oslo_config import cfg from oslo_middleware import base import webob.dec @@ -116,19 +117,19 @@ class CORS(base.Middleware): self.allowed_origins[allowed_origin] = conf[section] - @webob.dec.wsgify - def __call__(self, req): - # If it's an OPTIONS request, handle it immediately. Otherwise, - # pass it through to the application. + def process_request(self, req): + '''If we detect an OPTIONS request, handle it immediately.''' if req.method == 'OPTIONS': resp = webob.response.Response(status=webob.exc.HTTPOk.code) self._apply_cors_preflight_headers(request=req, response=resp) - else: - resp = req.get_response(self.application) - self._apply_cors_request_headers(request=req, response=resp) + return resp + + def process_response(self, response, request=None): + '''Detect CORS headers on the request, and decorate the response.''' + self._apply_cors_request_headers(request=request, response=response) # Finally, return the response. - return resp + return response def _split_header_values(self, request, header_name): """Convert a comma-separated header value into a list of values.""" |