Skip to content

middleware request transaction handling with deferred callable return for refresh of orm #8036

Discussion options

You must be logged in to vote

Is there a reason you can't just create a transaction in the middleware, and (if desired) a nested transaction inside the endpoint?

Having your routes return functions instead of responses is a major deviation from what starlette expects, and is likely to cause fragility. In particular, the suggested implementation would force you to return a response_func from all endpoints, even if they have no interaction with the sqlalchemy session.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by svlandeg
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
Converted from issue

This discussion was converted from issue #474 on February 28, 2023 11:53.