letitcrash

package module
v0.0.0-...-4667f43 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: MIT Imports: 17 Imported by: 0

README

Let it crash

A Go middleware to display debug information when an application is in a panic situation or needs to handle an error.

This middleware contains:

  • An enhanced console output of the error stacktrace using panicparse
  • An HTML debug error page which contains stacktrace and various information about request, environment, etc.

Do not use this middleware in production :)

Enhanced console output

...

Debug error page

...

Customization

...

Contributing

Don't hesitate ;)

Authors

  • Florent Messa

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultErrorHandler

func DefaultErrorHandler(err interface{}, w http.ResponseWriter, r *http.Request)

DefaultErrorHandler is an handler provided by letitcrash to render the error.

func HandleError

func HandleError(err interface{}, w http.ResponseWriter, r *http.Request, opts ...Option)

HandleError handles an error.

func HandleRecover

func HandleRecover(w http.ResponseWriter, r *http.Request, opts ...Option)

HandleRecover handles an error from a recover situation.

func Handler

func Handler(h http.Handler, opts ...Option) http.Handler

Handler is a MiddlewareFunc which implements the Middleware interface.

func PrintError

func PrintError(err interface{}, out io.Writer) error

PrintError handles error and format it to stdout.

func ServeHTTP

func ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc, opts ...Option)

ServeHTTP is a Negroni compatible interface.

func SetDefaultOptions

func SetDefaultOptions(opts ...Option)

SetDefaultOptions sets default options.

Types

type ErrorHandler

type ErrorHandler func(err interface{}, w http.ResponseWriter, r *http.Request)

ErrorHandler is an handler to render the error.

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request) error

HandlerFunc is a http.HandlerFunc which can return an error.

func (HandlerFunc) ServeHTTP

func (f HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP calls f(w, r).

type Option

type Option func(*Options)

Option is a functional option.

func WithConsole

func WithConsole(console bool) Option

WithConsole sets the console option.

func WithErrorHandler

func WithErrorHandler(errorHandler ErrorHandler) Option

WithErrorHandler sets the error handler option.

func WithVerbose

func WithVerbose(verbose bool) Option

WithVerbose sets the verbose option.

type Options

type Options struct {
	Verbose      *bool
	Console      *bool
	ErrorHandler ErrorHandler
}

Options are worker options.

func (Options) Merge

func (o Options) Merge(opts Options) Options

Merge merges two options.

Directories

Path Synopsis
examples
gin-gonic command
http command
test command

Jump to

Keyboard shortcuts

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