|
35 | 35 | import pkg_resources |
36 | 36 |
|
37 | 37 | from . import api_config_manager |
| 38 | +from . import api_exceptions |
38 | 39 | from . import api_request |
39 | 40 | from . import discovery_service |
40 | 41 | from . import errors |
@@ -92,6 +93,13 @@ def __init__(self, backend_wsgi_app, config_manager=None): |
92 | 93 | self._add_dispatcher('%sstatic/.*$' % base_path, |
93 | 94 | self.handle_api_static_request) |
94 | 95 |
|
| 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 | + |
95 | 103 | def _add_dispatcher(self, path_regex, dispatch_function): |
96 | 104 | """Add a request path and dispatch handler. |
97 | 105 |
|
@@ -157,15 +165,6 @@ def dispatch(self, request, start_response): |
157 | 165 | if dispatched_response is not None: |
158 | 166 | return dispatched_response |
159 | 167 |
|
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 | | - |
169 | 168 | # Call the service. |
170 | 169 | try: |
171 | 170 | return self.call_backend(request, start_response) |
|
0 commit comments