recovery

package module
v0.0.0-...-92e4238 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 11 Imported by: 0

README

Gopher

Go Recovery

An beautiful recovery middleware go GoLang..

Travis Software License Coverage Status Go Report Card GoDoc

Introduction

Todo

  • Add CC & BCC
  • Remove external dependencies.

Contributing

We welcome contributors, but please read the contributing document before making a pull request.

Licence

Code Copyright 2021 go mail. Code released under the MIT Licence.

Documentation

Index

Constants

View Source
const (
	// The amount of files in the stack to be retrieved.
	StackDepth = 200
	// How many files to move up in the runtime.Caller
	// before obtaining the stack.
	StackSkip = 2
)
View Source
const (
	MainLayout = "layout.gohtml"
)

Variables

This section is empty.

Functions

func Static

func Static(w http.ResponseWriter, r *http.Request)

Types

type Config

type Config struct {
	Code    int
	Error   interface{}
	TplFile string
	Data    TplData
}

type Data

type Data struct {
	Error      error
	StatusCode int
	Request    *http.Request
	//Stack      trace.Stack
	Debug bool
}

Data represents the main struct for sending back data to the template for recovery.

type Handler

type Handler struct {
	Debug bool
}

func New

func New(Debug bool) *Handler

func (*Handler) HTTPRecovery

func (h *Handler) HTTPRecovery(next http.Handler) http.Handler

HTTPRecovery hello

func (*Handler) Recover

func (h *Handler) Recover(cfg Config) []byte

Recover - TODO

type Recover

type Recover struct {
	// contains filtered or unexported fields
}

Recover defines

func (Recover) ParseTemplates

func (re Recover) ParseTemplates() (*template.Template, error)

func (*Recover) Tpl

func (re *Recover) Tpl() ([]byte, error)

type Recovery

type Recovery interface {
	Recover(cfg Config) []byte
	HttpRecovery(next http.Handler) http.Handler
}

type Request

type Request struct {
	URL        string
	Method     string
	IP         string
	Referer    string
	DataLength int64
	Body       string
	Headers    map[string][]string
	Query      map[string][]string
	Cookies    []*http.Cookie
}

Request represents the data obtained from the context with detailed information about the http request made.

type TplData

type TplData map[string]interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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