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
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
Click to show internal directories.
Click to hide internal directories.