From 96cc49e31e68446743e109fbb9aad8364d3ab933 Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Tue, 2 Feb 2021 01:07:29 +0200 Subject: [PATCH] fix method ignore on websocket route --- sanic/mixins/routes.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sanic/mixins/routes.py b/sanic/mixins/routes.py index 512f7dff..f567e837 100644 --- a/sanic/mixins/routes.py +++ b/sanic/mixins/routes.py @@ -26,7 +26,7 @@ class RouteMixin: def route( self, uri, - methods=frozenset({"GET"}), + methods=None, host=None, strict_slashes=None, stream=False, @@ -63,6 +63,9 @@ class RouteMixin: if strict_slashes is None: strict_slashes = self.strict_slashes + if not methods and not websocket: + methods = frozenset({"GET"}) + def decorator(handler): nonlocal uri nonlocal methods @@ -100,7 +103,7 @@ class RouteMixin: route = FutureRoute( handler, uri, - frozenset([x.upper() for x in methods]), + None if websocket else frozenset([x.upper() for x in methods]), host, strict_slashes, stream,