Adds handlers from a different Hug API to this one - to create a single API
(self, http_api, route="", base_url="", **kwargs)
| 176 | placement[exception_type] = (error_handler,) + placement.get(exception_type, tuple()) |
| 177 | |
| 178 | def extend(self, http_api, route="", base_url="", **kwargs): |
| 179 | """Adds handlers from a different Hug API to this one - to create a single API""" |
| 180 | self.versions.update(http_api.versions) |
| 181 | base_url = base_url or self.base_url |
| 182 | |
| 183 | for _router_base_url, routes in http_api.routes.items(): |
| 184 | self.routes.setdefault(base_url, OrderedDict()) |
| 185 | for item_route, handler in routes.items(): |
| 186 | for _method, versions in handler.items(): |
| 187 | for _version, function in versions.items(): |
| 188 | function.interface.api = self.api |
| 189 | self.routes[base_url].setdefault(route + item_route, {}).update(handler) |
| 190 | |
| 191 | for _sink_base_url, sinks in http_api.sinks.items(): |
| 192 | for url, sink in sinks.items(): |
| 193 | self.add_sink(sink, route + url, base_url=base_url) |
| 194 | |
| 195 | for middleware in http_api.middleware or (): |
| 196 | self.add_middleware(middleware) |
| 197 | |
| 198 | for version, handler in getattr(http_api, "_exception_handlers", {}).items(): |
| 199 | for exception_type, exception_handlers in handler.items(): |
| 200 | target_exception_handlers = self.exception_handlers(version) or {} |
| 201 | for exception_handler in exception_handlers: |
| 202 | if exception_type not in target_exception_handlers: |
| 203 | self.add_exception_handler(exception_type, exception_handler, version) |
| 204 | |
| 205 | for input_format, input_format_handler in getattr(http_api, "_input_format", {}).items(): |
| 206 | if not input_format in getattr(self, "_input_format", {}): |
| 207 | self.set_input_format(input_format, input_format_handler) |
| 208 | |
| 209 | for version, handler in http_api.not_found_handlers.items(): |
| 210 | if version not in self.not_found_handlers: |
| 211 | self.set_not_found_handler(handler, version) |
| 212 | |
| 213 | @property |
| 214 | def not_found_handlers(self): |
nothing calls this directly
no test coverage detected