Documentation
¶
Overview ¶
Package pattern provides a simple regexp pattern matching library majorly for constructing URL matchers.
Patterns in this package follow the follow approach in declaring custom match
segments.
pattern: /name/{id:[/\d+/]}/log/{date:[/\w+\W+/]} pattern: /name/:id
Index ¶
- func CheckPriority(patt string) int
- func CleanPath(p string) string
- func CleanSlashes(p string) string
- func HasKeyParam(p string) bool
- func HasParam(p string) bool
- func HasPick(p string) bool
- func IsEndless(s string) bool
- func RemoveBracket(s string) string
- func RemoveCurly(s string) string
- func SplitPattern(c string) []string
- func SplitPatternAndRemovePrefix(c string) []string
- func TrimEndSlashe(c string) string
- func TrimSlashes(c string) string
- func YankSpecial(val string) (string, string, bool)
- type Matchable
- type Matchers
- type Params
- type SegmentMatcher
- type URIMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPriority ¶
CheckPriority is used to return the priority of a pattern. 0 for highest(when no parameters). 1 for restricted parameters({id:[]}). 2 for no paramters. The first parameter catched is used for rating. The ratings go from highest to lowest .i.e (0-2).
func CleanSlashes ¶
CleanSlashes cleans all double forward slashes into one
func HasKeyParam ¶
HasKeyParam returns true/false if the special pattern {:[..]} exists in the string
func RemoveBracket ¶
RemoveBracket removes '[' and ']' from any string
func RemoveCurly ¶
RemoveCurly removes '{' and '}' from any string
func SplitPatternAndRemovePrefix ¶
SplitPatternAndRemovePrefix splits a pattern with the '/'
func TrimEndSlashe ¶
TrimEndSlashe removes the '/' at the end of string.
func TrimSlashes ¶
TrimSlashes removes the '/' at the beginning and end of string.
Types ¶
type Matchers ¶
type Matchers []Matchable
Matchers defines a list of machers for validating patterns with.
func SegmentList ¶
SegmentList returns list of SegmentMatcher which implements the Matchable interface, with each made of each segment of the pattern.
type SegmentMatcher ¶
SegmentMatcher defines a single piece of pattern to be matched against.
func (*SegmentMatcher) HasHash ¶
func (s *SegmentMatcher) HasHash() bool
HasHash returns true/false if this segment hash the hash.
func (*SegmentMatcher) IsParam ¶
func (s *SegmentMatcher) IsParam() bool
IsParam returns true/false if the segment is also a paramter.
func (*SegmentMatcher) Segment ¶
func (s *SegmentMatcher) Segment() string
Segment returns the original string that makes up this segment matcher.
func (*SegmentMatcher) Validate ¶
func (s *SegmentMatcher) Validate(m string) bool
Validate validates the value against the matcher.