File: handler.go

package info (click to toggle)
golang-airbrake-go 0.0~git20150109-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 76 kB
  • sloc: makefile: 3
file content (17 lines) | stat: -rw-r--r-- 410 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package airbrake

import (
	"net/http"
)

// CapturePanicHandler "middleware".
// Wraps the http handler so that all panics will be dutifully reported to airbrake
//
// Example:
//   http.HandleFunc("/", airbrake.CapturePanicHandler(MyServerFunc))
func CapturePanicHandler(app http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		defer CapturePanic(r)
		app(w, r)
	}
}