pattern_value

package
v3.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValuePatterns

func GetValuePatterns() map[string]func() ValuePattern

GetValuePatterns gets all create valuePattern function

func SetValuePattern

func SetValuePattern(name string, fun func() ValuePattern)

SetValuePattern sets create valuePattern function with @name

Types

type ScopeValuePattern

type ScopeValuePattern struct {
}

ScopeValuePattern matches with patterns like 'key=1~100', 'key=~100' or 'key=1~'

func (*ScopeValuePattern) Match

func (s *ScopeValuePattern) Match(pattern string, value string, url *common.URL, invocation protocol.Invocation, isWhenCondition bool) bool

func (*ScopeValuePattern) Priority

func (s *ScopeValuePattern) Priority() int64

func (*ScopeValuePattern) ShouldMatch

func (s *ScopeValuePattern) ShouldMatch(pattern string) bool

type ValuePattern

type ValuePattern interface {
	// ShouldMatch indicates whether the input is a specific pattern, for example, range pattern '1~100', wildcard pattern 'hello*', etc.
	ShouldMatch(pattern string) bool
	// Match indicates whether a pattern is matched with the request context
	Match(pattern string, value string, url *common.URL, invocation protocol.Invocation, isWhenCondition bool) bool
	// Priority returns a priority for this valuePattern
	// 0 to ^int(0) is better, smaller value by better priority
	Priority() int64
}

func GetValuePattern

func GetValuePattern(name string) ValuePattern

GetValuePattern gets create valuePattern function by name

func NewScopeValuePattern

func NewScopeValuePattern() ValuePattern

func NewWildcardValuePattern

func NewWildcardValuePattern() ValuePattern

type WildcardValuePattern

type WildcardValuePattern struct {
}

WildcardValuePattern evaluator must be the last one being executed. matches with patterns like 'key=hello', 'key=hello*', 'key=*hello', 'key=h*o' or 'key=*'

func (*WildcardValuePattern) Match

func (w *WildcardValuePattern) Match(pattern string, value string, url *common.URL, invocation protocol.Invocation, isWhenCondition bool) bool

func (*WildcardValuePattern) Priority

func (w *WildcardValuePattern) Priority() int64

func (*WildcardValuePattern) ShouldMatch

func (w *WildcardValuePattern) ShouldMatch(pattern string) bool

Jump to

Keyboard shortcuts

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