// Begin a transaction. func (p DbPlugin) BeforeRequest(c *revel.Controller) { txn, err := Db.Begin() if err != nil { panic(err) } c.Txn = txn }
// Commit the active transaction. func (p DbPlugin) AfterRequest(c *revel.Controller) { if err := c.Txn.Commit(); err != nil { if err != sql.ErrTxDone { panic(err) } } c.Txn = nil }