Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultUIStatic ¶ added in v1.1.0
Get default UI static files (prefixed by ui/).
Types ¶
type Engine ¶
Engine of all redirection.
func DefaultEngine ¶
func DefaultEngine(storage Storage, sink StatWriter) Engine
Create default engine based on provided storage and sink.
type JSONStorage ¶ added in v1.1.0
type JSONStorage struct { FileName string // File name to store and read // contains filtered or unexported fields }
Simple single-file storage. All rules saved as-is by JSON indented encoder to the provided file after each Set ops.
func (*JSONStorage) All ¶ added in v1.1.0
func (js *JSONStorage) All() ([]*Rule, error)
All rules stored in cache. Never returns error.
func (*JSONStorage) Get ¶ added in v1.1.0
func (js *JSONStorage) Get(url string) (string, bool)
Get single record from cache.
func (*JSONStorage) Reload ¶ added in v1.1.0
func (js *JSONStorage) Reload() error
Read all rules from file. Will not update cache if file will not exists.
func (*JSONStorage) Remove ¶ added in v1.1.0
func (js *JSONStorage) Remove(url string) error
Remove rule from cache and save dump to disk. Even if dump failed rule removed from cache.
type Rule ¶
type Rule struct { URL string // Matching URL (aka service name) LocationTemplate string // Go-Template of target location }
Single rule for redirection.
type StatReader ¶
type StatReader interface {
Visits(url string) int64 // Get number of visits for specific service/url
}
Stats reader.
type StatWriter ¶
type StatWriter interface {
Touch(url string) // Touch resource and increment counter (hot operation, should be fast)
}
Stats consumer.
type Stats ¶
type Stats interface { StatWriter StatReader }
Stats reader and writer.
func InMemoryStats ¶
func InMemoryStats() Stats
type Storage ¶
type Storage interface { Set(url string, locationTemplate string) error // add or replace rule Get(url string) (string, bool) // get location template. should return true if exists Remove(url string) error // remove rule (or ignore if not exists) All() ([]*Rule, error) // dump all save rules Reload() error // reload storage and fill the internal cache }
Rules storage type.
Click to show internal directories.
Click to hide internal directories.