Skip to content

Commit b9d00e3

Browse files
committed
1.0.1 fixes
Fixed add_handler not wrapping into ResourceRoute. Fixed middleware returning coroutine instead of response. Fixed compability with aiohttp 3.7.4.post0
1 parent e6585a8 commit b9d00e3

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*__pycache__*
1+
*__pycache__*
2+
aiohttp_dynamic.egg-info*

aiohttp_dynamic/middlewares.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class DynamicMiddleware(typing.Sized,
2828
add, get, and deletion of existing middleware handlers after run_app().
2929
"""
3030

31+
# Compability with old aiohttp version
32+
__middleware_version__: int = 1
33+
3134
_handlers: typing.List[typing.Callable[[web_request.Request, Handler], typing.Awaitable[web_response.StreamResponse]]]
3235

3336
def __init__(self, middlewares: typing.List[typing.Callable[[web_request.Request, Handler], typing.Awaitable[web_response.StreamResponse]]] = []) -> None:
@@ -78,4 +81,4 @@ async def __call__(self, request: web_request.Request, handler: Handler) -> web_
7881
for h in reversed(self._handlers):
7982
handler = functools.update_wrapper(functools.partial(h, handler=handler), handler)
8083

81-
return handler
84+
return await handler(request)

aiohttp_dynamic/routing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ def add_handler(self, method: str, handler: typing.Union[Handler, web_urldispatc
9494
if method == hdrs.METH_ANY:
9595
if method in self._routes:
9696
if overwrite:
97-
self._routes[method] = handler
97+
self._routes[method] = web_urldispatcher.ResourceRoute(method, handler, self)
9898
return True
9999
else:
100100
return False
101101
else:
102-
self._routes[method] = handler
102+
self._routes[method] = web_urldispatcher.ResourceRoute(method, handler, self)
103103
return True
104104

105105
# Strict check

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
setup(
44
name = 'aiohttp_dynamic',
55
packages = ['aiohttp_dynamic'],
6-
version = '1.0.0',
6+
version = '1.0.1',
77
license='Apache License 2.0',
88
description = 'aiohttp extension for creating and modifying dynamic routes in runtime',
99
author = 'bitrate16',
1010
author_email = 'bitrate16@gmail.com',
1111
url = 'https://github.com/bitrate16/aiohttp-dynamic',
12-
download_url = 'https://github.com/bitrate16/aiohttp-dynamic/archive/1.0.0.tar.gz',
12+
download_url = 'https://github.com/bitrate16/aiohttp-dynamic/archive/1.0.1.tar.gz',
1313
keywords = ['aiohttp', 'dynamic', 'routing', 'mutable', 'aiohttp-server'],
1414
install_requires = [
1515
'aiohttp',

0 commit comments

Comments
 (0)