errormw

package
v0.0.0-...-83625b3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MiddlewareDependencyError = "*errormw.ErrorHandlerMiddleware"
)

Variables

View Source
var (
	OtherForegroundColor   = "fdf6e3"
	WarningForegroundColor = "fdf6e3"
	ErrorForegroundColor   = "fdf6e3"
	OtherBackgroundColor   = "268bd2"
	WarningBackgroundColor = "b58900"
	ErrorBackgroundColor   = "dc322f"
)

Color codes for HTML error pages

View Source
var ErrorPage = template.Must(template.New("ErrorPage").Parse(`<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta charset="utf8" />
	<title>Error</title>
	<style type="text/css">
		body {
			background-color: #{{.BackgroundColor}};
			color: #{{.ForegroundColor}};
		}
	</style>
</head>
	<body>
		<h1>HTTP Error {{.Code}}</h1>
		<p>{{.Message}}</p>
		<hr/>
		{{if .RequestID}}<p> Request ID: {{.RequestID}} </p>
		<hr/>{{end}}
		<pre>{{.Logs}}</pre>
	</body>
</html>
`))

ErrorPage is the default HTML template for the standard HTML error page.

Functions

This section is empty.

Types

type ErrorHandlerMiddleware

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

ErrorHandlerMiddleware injects an ErrorHandler into the request context, and then recovers if the ErrorHandler paniced.

This middleware is automatically added to the Server with PetBunny.

func New

func New(displayErrors bool) *ErrorHandlerMiddleware

func (*ErrorHandlerMiddleware) Dependencies

func (e *ErrorHandlerMiddleware) Dependencies() []string

func (*ErrorHandlerMiddleware) Wrap

type ErrorPageData

type ErrorPageData struct {
	BackgroundColor string
	ForegroundColor string
	Code            int
	Message         string
	Logs            string
	RequestID       string
}

ErrorPageData contains data for the ErrorPage template.

func NewErrorPageData

func NewErrorPageData(code int, r *http.Request) ErrorPageData

Jump to

Keyboard shortcuts

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