recovery

package
v0.0.0-...-e92691c Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: MIT Imports: 3 Imported by: 0

README

Recovery!

Middleware package for recoving panic

Examples

func handler() http.Handler {
    retrun http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	    panic("this should not happen")
    })
}

var panicHandler = func(err interface{}, stacktrace []string, r *http.Request) {
    log.Println(err)
}

func main() {
    var p = Panic(panicHandler)
    http.Handle("/panic", p(handler()))
    log.Fatal(http.ListenAndServe(":8080", nil))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Panic

func Panic(p OnPanic) func(http.Handler) http.Handler

Panic ...

Types

type OnPanic

type OnPanic func(err interface{}, stacktrace []string, r *http.Request)

OnPanic ...

Jump to

Keyboard shortcuts

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