<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def require_session(handler):
 """ Decorator to ensure a session is properly in the request """

    @functools.wraps(handler)
    async def decorated(request: web.Request) -> web.Response:
        request_session_token = request.match_info['session']
        session = session_from_request(request)
        if not session or request_session_token != session.token:
            LOG.warning(f"request for invalid session {request_session_token}")
            return web.json_response(
                data={'error': 'bad-token',
                      'message': f'No such session {request_session_token}'},
                status=404)
        return await handler(request, session)
    return decorated