add match_info to request

This commit is contained in:
Yun Xu
2017-06-17 09:47:58 -07:00
parent e4669e2581
commit 20138ee85f
2 changed files with 18 additions and 0 deletions

View File

@@ -211,6 +211,19 @@ def test_content_type():
assert response.text == 'application/json'
def test_match_info():
app = Sanic('test_match_info')
@app.route('/api/v1/user/<user_id>/')
async def handler(request, user_id):
return json(request.match_info)
request, response = app.test_client.get('/api/v1/user/sanic_user/')
assert request.match_info == {"user_id": "sanic_user"}
assert json_loads(response.text) == {"user_id": "sanic_user"}
# ------------------------------------------------------------ #
# POST
# ------------------------------------------------------------ #