api: simplify root controller
There's no need to have a special /v1 handler that returns 404 since this is the default behavior of Pecan anyway. Change-Id: I1c8d4c90696436ec24091ab9f294818b9bb06ac3
This commit is contained in:
parent
b4ce94845e
commit
74790b7128
@ -86,21 +86,6 @@ def setup_app(pecan_config=None):
|
||||
return app
|
||||
|
||||
|
||||
class VersionSelectorApplication(object):
|
||||
def __init__(self):
|
||||
def not_found(environ, start_response):
|
||||
start_response('404 Not Found', [])
|
||||
return []
|
||||
|
||||
self.v1 = not_found
|
||||
self.v2 = setup_app()
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
if environ['PATH_INFO'].startswith('/v1/'):
|
||||
return self.v1(environ, start_response)
|
||||
return self.v2(environ, start_response)
|
||||
|
||||
|
||||
def load_app():
|
||||
# Build the WSGI app
|
||||
cfg_file = None
|
||||
@ -138,4 +123,4 @@ def build_server():
|
||||
|
||||
|
||||
def app_factory(global_config, **local_conf):
|
||||
return VersionSelectorApplication()
|
||||
return setup_app()
|
||||
|
@ -32,5 +32,5 @@ def load_tests(loader, tests, pattern):
|
||||
"""Provide a TestSuite to the discovery process."""
|
||||
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
||||
return driver.build_tests(test_dir, loader, host=None,
|
||||
intercept=app.VersionSelectorApplication,
|
||||
intercept=app.setup_app,
|
||||
fixture_module=fixture_module)
|
||||
|
@ -30,5 +30,5 @@ def load_tests(loader, tests, pattern):
|
||||
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
||||
return driver.build_tests(test_dir, loader, host=None,
|
||||
prefix='/telemetry',
|
||||
intercept=app.VersionSelectorApplication,
|
||||
intercept=app.setup_app,
|
||||
fixture_module=fixture_module)
|
||||
|
Loading…
Reference in New Issue
Block a user