Session Management Middleware

class falcon_sqla.middleware.Middleware(manager: Manager)

Falcon middleware that can be used with the session manager.

Parameters:

manager (Manager) – Manager instance to use in this middleware.

process_request(req: Request, resp: Response) None

Set up a SQLAlchemy session for this request.

The session object is stored as req.context.session.

When the sticky_binds option is set to True, a req.context.request_id identifier is created (if not already present) by calling the request_id_func function.

process_response(req: Request, resp: Response, resource: object | None, req_succeeded: bool) None

Clean up the session, if one was provided.

This response hook finalizes the session by calling the manager’s close_session() method.