allow using a list of hosts on a route

This commit is contained in:
Raphael Deem
2017-01-18 19:40:20 -08:00
parent e218a59911
commit 2c1ff5bf5d
3 changed files with 32 additions and 2 deletions

View File

@@ -76,8 +76,15 @@ class Router:
if self.hosts is None:
self.hosts = set(host)
else:
if isinstance(host, list):
host = set(host)
self.hosts.add(host)
uri = host + uri
if isinstance(host, str):
uri = host + uri
else:
for h in host:
self.add(uri, methods, handler, h)
return
# Dict for faster lookups of if method allowed
if methods: