Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit 1d717d4

Browse files
committed
Only register API config on startup, not every request.
That level of dynamicness is completely unnecessary.
1 parent ddb7b06 commit 1d717d4

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

endpoints/endpoints_dispatcher.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import pkg_resources
3636

3737
from . import api_config_manager
38+
from . import api_exceptions
3839
from . import api_request
3940
from . import discovery_service
4041
from . import errors
@@ -92,6 +93,13 @@ def __init__(self, backend_wsgi_app, config_manager=None):
9293
self._add_dispatcher('%sstatic/.*$' % base_path,
9394
self.handle_api_static_request)
9495

96+
# Get API configuration so we know how to call the backend.
97+
api_config_response = self.get_api_configs()
98+
if api_config_response:
99+
self.config_manager.process_api_config_response(api_config_response)
100+
else:
101+
raise api_exceptions.ApiConfigurationError('get_api_configs() returned no configs')
102+
95103
def _add_dispatcher(self, path_regex, dispatch_function):
96104
"""Add a request path and dispatch handler.
97105
@@ -157,15 +165,6 @@ def dispatch(self, request, start_response):
157165
if dispatched_response is not None:
158166
return dispatched_response
159167

160-
# Get API configuration first. We need this so we know how to
161-
# call the back end.
162-
api_config_response = self.get_api_configs()
163-
if api_config_response:
164-
self.config_manager.process_api_config_response(api_config_response)
165-
else:
166-
return self.fail_request(request, 'get_api_configs Error',
167-
start_response)
168-
169168
# Call the service.
170169
try:
171170
return self.call_backend(request, start_response)

0 commit comments

Comments
 (0)