top

Package bugsnagmartini provides a martini middleware that sends panics to Bugsnag. You should use this middleware in combination with martini.Recover() if you want to send error messages to your clients:

func main() {
	m := martini.New()
	// used to stop panics bubbling and return a 500 error.
	m.Use(martini.Recovery())

	// used to send panics to Bugsnag.
	m.Use(bugsnagmartini.AutoNotify(bugsnag.Configuration{
		APIKey: "YOUR_API_KEY_HERE",
	})

	// ...
}

This middleware also makes bugsnag available to martini handlers via the context.

func myHandler(w http.ResponseWriter, r *http.Request, bugsnag *bugsnag.Notifier) {
	// ...
	bugsnag.Notify(err)
	// ...
}

Imports 2 package(s) ΒΆ

  1. github.com/bugsnag/bugsnag-go
  2. github.com/go-martini/martini