middleware

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2016 License: MIT Imports: 6 Imported by: 0

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

func NewRelic added in v0.4.5

func NewRelic(key, name string) buffalo.MiddlewareFunc

NewRelic returns a piece of buffalo.Middleware that can be used to report requests to NewRelic. You must pass in your NewRelic key and a name for your application. If the key passed in is blank, i.e. loading from an ENV, then the middleware is skipped and the chain continues on like normal. Useful for development.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL