MCPcopy
hub / github.com/hugapi/hug / version_router

Method version_router

hug/api.py:347–357  ·  view source on GitHub ↗

Intelligently routes a request to the correct handler based on the version being requested

(
        self, request, response, api_version=None, versions=None, not_found=None, **kwargs
    )

Source from the content-addressed store, hash-verified

345 return handle_404
346
347 def version_router(
348 self, request, response, api_version=None, versions=None, not_found=None, **kwargs
349 ):
350 """Intelligently routes a request to the correct handler based on the version being requested"""
351 versions = {} if versions is None else versions
352 request_version = self.determine_version(request, api_version)
353 if request_version:
354 request_version = int(request_version)
355 versions.get(request_version or False, versions.get(None, not_found))(
356 request, response, api_version=api_version, **kwargs
357 )
358
359 def server(self, default_not_found=True, base_url=None):
360 """Returns a WSGI compatible API server for the given Hug API module"""

Callers

nothing calls this directly

Calls 2

determine_versionMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected