Skip to content
Discussion options

You must be logged in to vote

There's no hook for this in Wails, and the thing you'll find if you go searching for one is a trap. Middleware in Wails lives under pkg/options/assetserver and wraps the asset server's HTTP handler. Bound method calls never travel through it, so it reads like the answer and isn't.

The reason nothing exists is that bindings are generated by reflecting over your struct's exported methods and then invoked directly. There's no chain to insert yourself into.

What I'd do instead is keep the transaction in a helper the bound methods call through:

func (a *App) withTx(fn func(*sql.Tx) error) error {
	tx, err := a.db.Begin()
	if err != nil {
		return err
	}
	defer func() {
		if p := recover(); p != 

Replies: 1 comment 1 reply

Comment options

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

Answer selected by fkdp06
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