matcher

package
v0.0.0-...-69ee5db Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound       = errors.New("not found")
	ErrTagsNotAllowed = errors.New("tags not allowed")
	ErrTSR            = errors.New("TSR")
)

Functions

func Param

func Param(c context.Context, key string) string

Param returns the value of a url param base on the passed context

func Print

func Print(ma Matcher) string

Types

type Config

type Config struct {
	ParamChar        byte
	WildcardChar     byte
	Separators       string
	ParamTransformer ParamTransformer
	New              func() Store
}

type Context

type Context interface {
	context.Context
	Param(key string) string
	ParamOk(key string) (string, bool)
	AddParam(key, value string)
	Remove(key string)
	Reset()
	SearchHistory() []string
}

Context implements context.Context and stores values of url parameters

func C

func C(c context.Context) Context

C returns a Context based on a context.Context passed. If it does not convert to Context, it creates a new one with the context passed as argument.

func NewContext

func NewContext() Context

NewContext creates a new context instance

func NewContextWithParent

func NewContextWithParent(c context.Context) Context

NewContextWithParent creates a new context with a parent context specified

type Matcher

type Matcher interface {
	Set(pattern string, values interface{}, tags Tags) Store
	Get(pattern string, tags Tags) (Context, interface{}, error)
	GetWithContext(c Context, pattern string, tags Tags) (interface{}, error)
	Eval(pattern string, params map[string]string) (string, error)
}

func Custom

func Custom(cfg *Config) Matcher

func New

func New() Matcher

type ParamTransformer

type ParamTransformer interface {
	Transform(input string) (output string)
}

type Parameter

type Parameter struct {
	Key string
	Val string
}

type Store

type Store interface {
	Set(value interface{}, tags Tags)
	Get(tags Tags) interface{}
}

type Tags

type Tags []string

Jump to

Keyboard shortcuts

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