1. @app.on_request
    2. async def run_before_handler(request):
    3. request.ctx.user = await fetch_user_by_token(request.token)
    4. @app.route('/hi')
    5. async def hi_my_name_is(request):
    6. return text("Hi, my name is {}".format(request.ctx.user.name))
    1. @app.on_request
    2. async def increment_foo(request):
    3. if not hasattr(request.conn_info.ctx, "foo"):
    4. request.conn_info.ctx.foo = 0
    5. request.conn_info.ctx.foo += 1
    6. @app.get("/")
    7. async def count_foo(request):
    8. return text(f"request.conn_info.ctx.foo={request.conn_info.ctx.foo}")
    1. @app.route('/tag/<tag>')
    2. async def tag_handler(request, tag):
    3. return text("Tag - {}".format(tag))
    1. $ curl http://localhost:8000?key1=val1&key2=val2&key1=val3
    1. >>> print(request.args)
    2. {'key1': ['val1', 'val3'], 'key2': ['val2']}
    3. >>> print(request.args.get("key1"))
    4. val1
    5. >>> print(request.args.getlist("key1"))
    6. ['val1', 'val3']
    7. >>> print(request.query_args)
    8. [('key1', 'val1'), ('key2', 'val2'), ('key1', 'val3')]
    9. >>> print(request.query_string)
    10. key1=val1&key2=val2&key1=val3