From 0a160c4a0b7581a51229efc10928541e8752f6b9 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Thu, 19 Jan 2017 23:56:51 +0900 Subject: [PATCH] For function decorators, ['GET'] is the default methods --- sanic/blueprints.py | 2 +- sanic/sanic.py | 2 +- tests/test_routes.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sanic/blueprints.py b/sanic/blueprints.py index 583aa244..101c698f 100644 --- a/sanic/blueprints.py +++ b/sanic/blueprints.py @@ -87,7 +87,7 @@ class Blueprint: for deferred in self.deferred_functions: deferred(state) - def route(self, uri, methods=None, host=None): + def route(self, uri, methods=frozenset({'GET'}), host=None): """ """ def decorator(handler): diff --git a/sanic/sanic.py b/sanic/sanic.py index 94fcd983..5182b9fb 100644 --- a/sanic/sanic.py +++ b/sanic/sanic.py @@ -46,7 +46,7 @@ class Sanic: # -------------------------------------------------------------------- # # Decorator - def route(self, uri, methods=None, host=None): + def route(self, uri, methods=frozenset({'GET'}), host=None): """ Decorates a function to be registered as a route :param uri: path of the URL diff --git a/tests/test_routes.py b/tests/test_routes.py index 9c671829..be1fb29e 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -497,7 +497,7 @@ def test_overload_routes(): def test_unmergeable_overload_routes(): app = Sanic('test_dynamic_route') - @app.route('/overload_whole') + @app.route('/overload_whole', methods=None) async def handler1(request): return text('OK1')