예제 #1
0
    async def dispatch(
        self, request: Request, call_next: RequestResponseEndpoint,
    ):
        request_id = str(uuid4())
        token = session_context.set(request_id)

        try:
            response = await call_next(request)
        except Exception as e:
            session.rollback()
            raise e
        finally:
            session.remove()
            session_context.reset(token)

        return response
예제 #2
0
 async def remove_session(request: Request, call_next):
     response = await call_next(request)
     session.remove()
     return response
예제 #3
0
 def after_request(response: Response) -> Response:
     session.remove()
     return response