Merge pull request #471 from r0fls/vhost-default

allow default vhost
This commit is contained in:
Eli Uriegas
2017-02-22 11:08:28 -06:00
committed by GitHub
3 changed files with 40 additions and 11 deletions

View File

@@ -36,3 +36,21 @@ def test_vhosts_with_list():
headers = {"Host": "world.com"}
request, response = app.test_client.get('/', headers=headers)
assert response.text == "Hello, world!"
def test_vhosts_with_defaults():
app = Sanic('test_vhosts')
@app.route('/', host="hello.com")
async def handler(request):
return text("Hello, world!")
@app.route('/')
async def handler(request):
return text("default")
headers = {"Host": "hello.com"}
request, response = app.test_client.get('/', headers=headers)
assert response.text == "Hello, world!"
request, response = app.test_client.get('/')
assert response.text == "default"