Skip to content
Discussion options

You must be logged in to vote

@BashkaMen ,

Middlewares are not supposed to call endpoints, they are supposed to be executed ahead of endpoint handlers.
However, middlewares can equip endpoint handlers with a context that the framework calls options.
Those options can contain such entities as transaction or even callbacks for either to commit or rollback.
If the endpoint handler throws, that error goes to ResultHandler.
You can make a custom one (instead of defaultResultHandler), which could also get those options and perform the rollback in case of an error.

So, here is the suggested architecture:

  1. a Middleware that returns { commit, rollback } (callbacks),
  2. a ResultHandler that in case of error takes rollback from opt…

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@BashkaMen
Comment options

Answer selected by RobinTail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants