Version: v0.0.0-...-cd5d9a0 Latest Latest

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

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 8 Imported by: 0




This section is empty.


This section is empty.


func Decorate

func Decorate(h http.Handler, dd ...Decorator) http.Handler

Decorate applies a bunch of decorators to an http.Handler.

func StyleHandler

func StyleHandler() http.Handler


type Cache

type Cache struct {
	// contains filtered or unexported fields

Cache is a collection of Pairs with a fixed capacity.

func NewCache

func NewCache(cap int) (*Cache, error)

Returns a new Cache with the given capacity.

func (*Cache) Add

func (c *Cache) Add(pairs ...pair.Pair)

Add adds some pairs to the cache. If the number of pairs in the cache exceeds its capacity, the oldest surplus pairs will be deleted.

func (*Cache) Get

func (c *Cache) Get() []pair.Pair

Get returns all the pairs in the cache, in reverse chronological order.

type Decorator

type Decorator func(http.Handler) http.Handler

Decorator decorates http.Handlers.

func WithLogs

func WithLogs(l Logger) Decorator

type Logger

type Logger interface {
	Printf(string, ...interface{})

Logger knows how to log messages.

type Popularity

type Popularity struct {
	// contains filtered or unexported fields

Popularity keeps track of pairs and allow to generate an HTML representation of the newest ones. It has a miximum capcacity of pairs: when adding new pairs, the surplus oldest ones will be forgotten.

The Add and HTML methods are thread-safe.

func NewPopularity

func NewPopularity(cap int) (*Popularity, error)

NewPopularity returns a new Popularity with the given capacity.

func (*Popularity) Add

func (p *Popularity) Add(pairs ...pair.Pair) error

Add adds the given pairs to the web page.

func (*Popularity) HTML

func (p *Popularity) HTML() []byte

HTML returns a web page with the newest pairs added.

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