forked from bugsnag/bugsnag-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gin.go
38 lines (31 loc) · 754 Bytes
/
gin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"github.com/bugsnag/bugsnag-go"
"github.com/bugsnag/bugsnag-go/gin"
"github.com/gin-gonic/gin"
"net/http"
"os"
)
func main() {
g := gin.Default()
g.Use(bugsnaggin.AutoNotify(bugsnag.Configuration{
APIKey: "166f5ad3590596f9aa8d601ea89af845",
Endpoint: os.Getenv("BUGSNAG_ENDPOINT"),
}))
if os.Getenv("BUGSNAG_TEST_VARIANT") == "beforenotify" {
bugsnag.OnBeforeNotify(func(event *bugsnag.Event, config *bugsnag.Configuration) error {
event.Severity = bugsnag.SeverityInfo
return nil
})
}
g.GET("/", performUnhandledCrash)
g.Run(":9079")
}
func performUnhandledCrash(c *gin.Context) {
c.String(http.StatusOK, "OK")
var a struct{}
crash(a)
}
func crash(a interface{}) string {
return a.(string)
}