code: def require_session(handler):
      
      @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
docs: Decorator to ensure a session is properly in the request