ravenchi

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: Unlicense Imports: 7 Imported by: 0

README

ravenchi

Ravenchi implement a middleware for report panic to sentry.io using the raven-go client. It also integrate with chi middleware ecosystem by logging any appropriate informations.

raven-go client must be initialize with SetDSN() or by using environment variables

Here is an example on how to use the middleware.

r := chi.NewRouter()

// Apply the middleware to the router
r.Use(ravenchi.SentryRecovery)

r.Get("/", func(w http.ResponseWriter, r *http.Request) {
    panic("catched")
})

Documentation

Overview

Package ravenchi implement a middleware for report panic to sentry.io. It also integrate with chi middleware ecosystem by logging any appropriate informations

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SentryRecovery

func SentryRecovery(handler http.Handler) http.Handler

SentryRecovery recover from panic, report the error back to sentry, log it, and return an internal server error back to the user.

Example
package main

import (
	"net/http"

	"github.com/go-chi/chi"
	"github.com/loikg/ravenchi"
)

func main() {
	r := chi.NewRouter()

	// Apply the middleware to the router
	r.Use(ravenchi.SentryRecovery)

	r.Get("/", func(w http.ResponseWriter, r *http.Request) {
		panic("catched")
	})
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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