fix method ignore on websocket route

This commit is contained in:
Adam Hopkins 2021-02-02 01:07:29 +02:00
parent 94e5f82a81
commit 96cc49e31e

View File

@ -26,7 +26,7 @@ class RouteMixin:
def route( def route(
self, self,
uri, uri,
methods=frozenset({"GET"}), methods=None,
host=None, host=None,
strict_slashes=None, strict_slashes=None,
stream=False, stream=False,
@ -63,6 +63,9 @@ class RouteMixin:
if strict_slashes is None: if strict_slashes is None:
strict_slashes = self.strict_slashes strict_slashes = self.strict_slashes
if not methods and not websocket:
methods = frozenset({"GET"})
def decorator(handler): def decorator(handler):
nonlocal uri nonlocal uri
nonlocal methods nonlocal methods
@ -100,7 +103,7 @@ class RouteMixin:
route = FutureRoute( route = FutureRoute(
handler, handler,
uri, uri,
frozenset([x.upper() for x in methods]), None if websocket else frozenset([x.upper() for x in methods]),
host, host,
strict_slashes, strict_slashes,
stream, stream,