Documentation ¶
Index ¶
- func HeadersContainCode(headers *fasthttp.RequestHeader) (ok bool)
- func New(cfg *config.Config, log *logger.Logger) (_ fasthttp.RequestHandler, closeCache func())
- func URLContainsCode(url string) (ok bool)
- type RenderedCache
- func (rc *RenderedCache) Clear()
- func (rc *RenderedCache) ClearExpired()
- func (rc *RenderedCache) Get(template string, props template.Props) ([]byte, bool)
- func (rc *RenderedCache) Has(template string, props template.Props) bool
- func (rc *RenderedCache) Put(template string, props template.Props, content []byte)
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 ¶
New creates a new handler that returns an error page with the specified status code and format.
func URLContainsCode ¶
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 ¶
Get returns the content of the item with the specified template and props.