Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PopTransaction = func(db *pop.Connection) buffalo.MiddlewareFunc { return func(h buffalo.Handler) buffalo.Handler { return func(c buffalo.Context) error { return db.Transaction(func(tx *pop.Connection) error { start := tx.Elapsed defer func() { finished := tx.Elapsed elapsed := time.Duration(finished - start) c.LogField("db", elapsed) }() c.Set("tx", tx) return h(c) }) } } }
PopTransaction is a piece of Buffalo middleware that wraps each request in a transaction that will automatically get committed or rolledback. It will also add a field to the log, "db", that shows the total duration spent during the reques making database calls.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.