package
0.8.9
Repository: https://github.com/influx6/npkg.git
Documentation: pkg.go.dev

# README

Pattern

GoDoc

Pattern provides a simple URI pattern matcher, useful for constructing url matchers.

Example


package main

import "github.com/influx6/faux/pattern"
import "fmt"

func main(){

	r := pattern.New(`/name/{id:[\d+]}/`)

	params, state := r.Validate(`/name/12/d`)
  if !state {
    panic("No match found")
  }

  fmt.Printf("URL Params: %+s",params)
}

# Functions

CheckPriority is used to return the priority of a npattrn.
CleanPath provides a public path cleaner.
CleanSlashes cleans all double forward slashes into one.
HasKeyParam returns true/false if the special npattrn {:[..]} exists in the string.
HasParam returns true/false if the special npattrn {:[..]} exists in the string.
HasPick matches string of type :id,:name.
IsEndless returns true/false if the npattrn as a /*.
New returns a new instance of a URIMatcher.
RemoveBracket removes '[' and ']' from any string.
RemoveCurly removes '{' and '}' from any string.
Segment returns a Matchable for a specific part of a npattrn eg.
SegmentList returns list of SegmentMatcher which implements the Matchable interface, with each made of each segment of the npattrn.
SplitPattern splits a npattrn with the '/'.
SplitPatternAndRemovePrefix splits a npattrn with the '/'.
TrimEndSlashe removes the '/' at the end of string.
TrimSlashes removes the '/' at the beginning and end of string.
YankSpecial provides a means of extracting parts of form `{id:[\d+]}`.

# Structs

SegmentMatcher defines a single piece of npattrn to be matched against.

# Interfaces

Matchable defines an interface for matchers.
URIMatcher defines an interface for a URI matcher.

# Type aliases

Matchers defines a list of machers for validating patterns with.
Params defines a map of stringed keys and values.