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.

Files changed (37) hide show
  1. {cadwyn-3.10.1 → cadwyn-3.11.0}/PKG-INFO +1 -1
  2. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/applications.py +1 -0
  3. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/routing.py +10 -5
  4. {cadwyn-3.10.1 → cadwyn-3.11.0}/pyproject.toml +1 -1
  5. {cadwyn-3.10.1 → cadwyn-3.11.0}/LICENSE +0 -0
  6. {cadwyn-3.10.1 → cadwyn-3.11.0}/README.md +0 -0
  7. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/__init__.py +0 -0
  8. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/__main__.py +0 -0
  9. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_asts.py +0 -0
  10. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_compat.py +0 -0
  11. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_package_utils.py +0 -0
  12. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/_utils.py +0 -0
  13. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/README.md +0 -0
  14. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/__init__.py +0 -0
  15. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_common.py +0 -0
  16. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_main.py +0 -0
  17. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/__init__.py +0 -0
  18. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/class_migrations.py +0 -0
  19. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/class_rebuilding.py +0 -0
  20. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/class_renaming.py +0 -0
  21. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/import_auto_adding.py +0 -0
  22. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/codegen/_plugins/module_migrations.py +0 -0
  23. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/exceptions.py +0 -0
  24. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/main.py +0 -0
  25. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/middleware.py +0 -0
  26. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/py.typed +0 -0
  27. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/route_generation.py +0 -0
  28. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/static/__init__.py +0 -0
  29. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/static/docs.html +0 -0
  30. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/__init__.py +0 -0
  31. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/common.py +0 -0
  32. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/data.py +0 -0
  33. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/endpoints.py +0 -0
  34. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/enums.py +0 -0
  35. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/modules.py +0 -0
  36. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/schemas.py +0 -0
  37. {cadwyn-3.10.1 → cadwyn-3.11.0}/cadwyn/structure/versions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cadwyn
3
- Version: 3.10.1
3
+ Version: 3.11.0
4
4
  Summary: Production-ready community-driven modern Stripe-like API versioning in FastAPI
5
5
  Home-page: https://github.com/zmievsa/cadwyn
6
6
  License: MIT
@@ -127,6 +127,7 @@ class Cadwyn(FastAPI):
127
127
  deprecated=deprecated,
128
128
  responses=responses,
129
129
  api_version_header_name=api_version_header_name,
130
+ api_version_var=self.versions.api_version_var,
130
131
  lifespan=lifespan,
131
132
  )
132
133
  self.docs_url = docs_url
@@ -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__(self, *args: Any, api_version_header_name: str, **kwargs: Any):
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
- request_headers = dict(scope["headers"])
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cadwyn"
3
- version = "3.10.1"
3
+ version = "3.11.0"
4
4
  description = "Production-ready community-driven modern Stripe-like API versioning in FastAPI"
5
5
  authors = ["Stanislav Zmiev <zmievsa@gmail.com>"]
6
6
  license = "MIT"
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