errorpage

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package errorpage provides error page loading utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort

func Sort(pages Pages)

Sort pages by specificity.

Types

type Page

type Page struct {
	Name     string
	Code     int
	Range    bool
	Template *template.Template
}

Page is a single .html file matching one or more status codes.

func (*Page) Match

func (p *Page) Match(code int) bool

Match returns true if the page matches code.

func (*Page) Render

func (p *Page) Render(data interface{}) (string, error)

Render the page.

func (*Page) Specificity

func (p *Page) Specificity() int

Specificity returns the specificity, where higher is more precise.

type Pages

type Pages []Page

Pages is a group of .html files matching one or more status codes.

func Load

func Load(dir string) (pages Pages, err error)

Load pages in dir.

func (Pages) Match

func (p Pages) Match(code int) *Page

Match returns the matching page.

Jump to

Keyboard shortcuts

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