Generic airbraker that integrated with airbrake service for Gin-backed web application
Set up environment variables.
$ export AIRBRAKE_PROJECT_ID="your-project-id"
$ export AIRBRAKE_TOKEN="your-token"
$ export AIRBRAKE_ENV="your-app-env"
package main
import (
"github.com/gin-gonic/gin"
"github.com/theplant/airbraker"
)
func main() {
r := gin.Default()
// Set up recover middleware
r.Use(airbraker.Recover())
r.GET("/panic", func(c *gin.Context) {
panic(errors.New("unexpected error"))
})
r.Run() // listen and server on 0.0.0.0:8080
}
After you start with go run main.go
. You'll see:
Logging errors to Airbrake '<AIRBRAKE_ENV>' env on project <AIRBRAKE_PROJECT_ID>
Then it works. :)