cadwyn 3.10.1__tar.gz → 3.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cadwyn might be problematic. Click here for more details.
- {cadwyn-3.10.1 → cadwyn-3.11.0}/PKG-INFO +1 -1
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/applications.py +1 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/routing.py +10 -5
- {cadwyn-3.10.1 → cadwyn-3.11.0}/pyproject.toml +1 -1
- {cadwyn-3.10.1 → cadwyn-3.11.0}/LICENSE +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/README.md +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/__init__.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/__main__.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_asts.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_compat.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_package_utils.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_utils.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/README.md +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/__init__.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_common.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_main.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/__init__.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/class_migrations.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/class_rebuilding.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/class_renaming.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/import_auto_adding.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/module_migrations.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/exceptions.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/main.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/middleware.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/py.typed +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/route_generation.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/static/__init__.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/static/docs.html +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/__init__.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/common.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/data.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/endpoints.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/enums.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/modules.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/schemas.py +0 -0
- {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/versions.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import bisect
|
|
2
2
|
from collections import OrderedDict
|
|
3
3
|
from collections.abc import Sequence
|
|
4
|
+
from contextvars import ContextVar
|
|
4
5
|
from datetime import date
|
|
5
6
|
from functools import cached_property
|
|
6
7
|
from logging import getLogger
|
|
@@ -35,11 +36,18 @@ class _RootHeaderAPIRouter(APIRouter):
|
|
|
35
36
|
matched to the higher versioned route
|
|
36
37
|
"""
|
|
37
38
|
|
|
38
|
-
def __init__(
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
*args: Any,
|
|
42
|
+
api_version_header_name: str,
|
|
43
|
+
api_version_var: ContextVar[date] | ContextVar[date | None],
|
|
44
|
+
**kwargs: Any,
|
|
45
|
+
):
|
|
39
46
|
super().__init__(*args, **kwargs)
|
|
40
47
|
self.versioned_routes: dict[date, list[BaseRoute]] = {}
|
|
41
48
|
self.unversioned_routes: list[BaseRoute] = []
|
|
42
49
|
self.api_version_header_name = api_version_header_name.lower()
|
|
50
|
+
self.api_version_var = api_version_var
|
|
43
51
|
|
|
44
52
|
@cached_property
|
|
45
53
|
def sorted_versioned_routes(self):
|
|
@@ -90,10 +98,7 @@ class _RootHeaderAPIRouter(APIRouter):
|
|
|
90
98
|
await self.lifespan(scope, receive, send)
|
|
91
99
|
return
|
|
92
100
|
|
|
93
|
-
|
|
94
|
-
header_value = request_headers.get(self.api_version_header_name.encode(), b"").decode()
|
|
95
|
-
if header_value:
|
|
96
|
-
header_value = date.fromisoformat(header_value)
|
|
101
|
+
header_value = self.api_version_var.get(None)
|
|
97
102
|
|
|
98
103
|
# if header_value is None, then it's an unversioned request and we need to use the unversioned routes
|
|
99
104
|
# if there will be a value, we search for the most suitable version
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|