error_page

package
v1.8.1-0...-791fd1a Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeadersContainCode

func HeadersContainCode(headers *fasthttp.RequestHeader) (ok bool)

HeadersContainCode checks if the given headers contain an error code.

func New

func New(cfg *config.Config, log *logger.Logger) (_ fasthttp.RequestHandler, closeCache func())

New creates a new handler that returns an error page with the specified status code and format.

func URLContainsCode

func URLContainsCode(url string) (ok bool)

URLContainsCode checks if the given URL contains an error code.

Types

type RenderedCache

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

RenderedCache is a cache for rendered error pages. It's safe for concurrent use. It uses a hash of the template and props as a key.

To remove expired items, call ClearExpired method periodically (a bit more often than the ttl).

func NewRenderedCache

func NewRenderedCache(ttl time.Duration) *RenderedCache

NewRenderedCache creates a new RenderedCache with the specified ttl.

func (*RenderedCache) Clear

func (rc *RenderedCache) Clear()

Clear removes all items from the cache.

func (*RenderedCache) ClearExpired

func (rc *RenderedCache) ClearExpired()

ClearExpired removes all expired items from the cache.

func (*RenderedCache) Get

func (rc *RenderedCache) Get(template string, props template.Props) ([]byte, bool)

Get returns the content of the item with the specified template and props.

func (*RenderedCache) Has

func (rc *RenderedCache) Has(template string, props template.Props) bool

Has checks if the cache has an item with the specified template and props.

func (*RenderedCache) Put

func (rc *RenderedCache) Put(template string, props template.Props, content []byte)

Put adds a new item to the cache with the specified template, props, and content.

Jump to

Keyboard shortcuts

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