matcher
v0.0.0-20191115102631-69ee5db2c99e
github.com/celrenheit/lion/internal/matcher
Documentation
pkg.go.dev ↗Variables
ErrNotFound (3 declarations)
var (
ErrNotFound = errors.New("not found")
ErrTagsNotAllowed = errors.New("tags not allowed")
ErrTSR = errors.New("TSR")
)
Functions
Param
func Param(c context.Context, key string) string
Param returns the value of a url param base on the passed context
func Print(ma Matcher) string
Types
Config
type Config struct {
ParamChar byte
WildcardChar byte
Separators string
ParamTransformer ParamTransformer
New func() Store
}
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
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.
NewContext
func NewContext() Context
NewContext creates a new context instance
NewContextWithParent
func NewContextWithParent(c context.Context) Context
NewContextWithParent creates a new context with a parent context specified
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)
}
Custom
func Custom(cfg *Config) Matcher
New
func New() Matcher
ParamTransformer
type ParamTransformer interface {
Transform(input string) (output string)
}
Parameter
type Parameter struct {
Key string
Val string
}
Store
type Store interface {
Set(value interface{}, tags Tags)
Get(tags Tags) interface{}
}
Tags
type Tags []string