accept strict_slash routes

This commit is contained in:
Raphael Deem
2017-03-15 21:11:45 -07:00
parent fa69892f70
commit 46677e69ce
3 changed files with 65 additions and 23 deletions

View File

@@ -95,9 +95,15 @@ class Router:
return name, _type, pattern
def add(self, uri, methods, handler, host=None):
def add(self, uri, methods, handler, host=None, strict_slashes=False):
# add regular version
self._add(uri, methods, handler, host)
if strict_slashes:
return
# Add versions with and without trailing /
slash_is_missing = (
not uri[-1] == '/'
and not self.routes_all.get(uri + '/', False)