From 4e6e364467f0e82d679c4b2640a8d266aaa4e7bf Mon Sep 17 00:00:00 2001 From: Raphael Deem Date: Sat, 19 Aug 2017 23:20:27 -0700 Subject: [PATCH] raise error when method/route overlap --- sanic/router.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sanic/router.py b/sanic/router.py index c0cb226d..4bb6e698 100644 --- a/sanic/router.py +++ b/sanic/router.py @@ -234,6 +234,12 @@ class Router: if route and merge_routes: route = merge_route(route, methods, handler) + elif route and route.methods.intersection(methods): + # already existing method is not overloadable. + duplicated = methods.intersection(route.methods) + raise RouteExists( + "Route already registered: {} [{}]".format( + uri, ','.join(list(duplicated)))) else: # prefix the handler name with the blueprint name # if available