errorpage

package
Version: v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorPageTemplateExample = `` /* 1172-byte string literal not displayed */

ErrorPageTemplateExample is a basic template for customizing the error page.

Variables

This section is empty.

Functions

func AuthenticationErrorCode

func AuthenticationErrorCode(err error) string

AuthenticationErrorCode returns an error code for the given authentication error. If the error is not recognized, a generic error code is returned.

func AuthenticationErrorMessage

func AuthenticationErrorMessage(code string) string

AuthenticationErrorMessage returns an error message for the given authentication error code. If the error code is not recognized, a generic error message is returned.

func GrantErrorCode

func GrantErrorCode(err error) string

GrantErrorCode returns an error code for the given grant error. If the error is not recognized, a generic error code is returned.

func GrantErrorMessage

func GrantErrorMessage(code string) string

GrantErrorMessage returns an error message for the given grant error code. If the error is not recognized, a generic error message is returned.

func ValidateErrorPageTemplate

func ValidateErrorPageTemplate(templateContent []byte) []error

ValidateErrorPageTemplate ensures the given template does not error when rendered with an ErrorData object as input

Types

type ErrorData

type ErrorData struct {
	Error     string
	ErrorCode string
}

ErrorData holds fields for the error page renderer

type ErrorPage

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

ErrorPage implements auth and grant error handling by rendering an error page for browser-like clients

func NewErrorPageHandler

func NewErrorPageHandler(renderer ErrorPageRenderer) *ErrorPage

NewErrorPageHandler returns an auth and grant error handler using the given renderer

func (*ErrorPage) AuthenticationError

func (p *ErrorPage) AuthenticationError(err error, w http.ResponseWriter, req *http.Request) (bool, error)

func (*ErrorPage) GrantError

func (p *ErrorPage) GrantError(err error, w http.ResponseWriter, req *http.Request) (bool, error)

type ErrorPageRenderer

type ErrorPageRenderer interface {
	Render(data ErrorData, w http.ResponseWriter, req *http.Request)
}

ErrorPageRenderer handles rendering a given error code/message

func NewErrorPageTemplateRenderer

func NewErrorPageTemplateRenderer(templateFile string) (ErrorPageRenderer, error)

NewErrorPageRenderer creates an error page renderer that takes in an optional custom template to allow branding of the page. Uses the default if templateFile is not set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL