rest: enable CORS middleware without Paste

It's impossible to pass a ConfigObj via Paste, so let's just embed it in
our application directly.

Change-Id: Iac4bc42102b02e996159e65df223ae09a2ca10d5
This commit is contained in:
Julien Danjou 2016-07-18 17:11:22 +02:00
parent 2aa755356e
commit db0eb3fdc1
2 changed files with 5 additions and 7 deletions

View File

@ -13,10 +13,10 @@ use = egg:Paste#urlmap
/v1 = gnocchiv1+auth
[pipeline:gnocchiv1+noauth]
pipeline = cors gnocchiv1
pipeline = gnocchiv1
[pipeline:gnocchiv1+auth]
pipeline = cors keystone_authtoken gnocchiv1
pipeline = keystone_authtoken gnocchiv1
[app:gnocchiversions]
paste.app_factory = gnocchi.rest.app:app_factory
@ -29,7 +29,3 @@ root = gnocchi.rest.V1Controller
[filter:keystone_authtoken]
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
oslo_config_project = gnocchi
[filter:cors]
paste.filter_factory = oslo_middleware.cors:filter_factory
oslo_config_project = gnocchi

View File

@ -18,6 +18,7 @@ import uuid
from oslo_config import cfg
from oslo_log import log
from oslo_middleware import cors
from oslo_policy import policy
from paste import deploy
import pecan
@ -128,7 +129,8 @@ def _setup_app(root, conf, indexer, storage, not_implemented_middleware):
def app_factory(global_config, **local_conf):
global APPCONFIGS
appconfig = APPCONFIGS.get(global_config.get('configkey'))
return _setup_app(root=local_conf.get('root'), **appconfig)
app = _setup_app(root=local_conf.get('root'), **appconfig)
return cors.CORS(app, conf=appconfig['conf'])
def build_wsgi_app():