pathmatch.Pattern.String()

master
Charles Iliya Krempeaux 2019-06-24 14:05:08 -07:00
parent 4b0308c64e
commit 64422ea7ec
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package pathmatch_test
import (
"github.com/reiver/go-pathmatch"
"fmt"
"os"
)
func ExamplePatternString() {
var template = "/v1/users/{user_id}"
var pattern pathmatch.Pattern
err := pathmatch.CompileTo(&pattern, template)
if nil != err {
fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
return
}
fmt.Printf("pattern: %s", pattern)
// Output:
// pattern: /v1/users/{user_id}
}

View File

@ -32,6 +32,7 @@ import (
// }
type Pattern struct {
mutex sync.RWMutex
template string
bits []string
names []string
namesSet map[string]struct{}

View File

@ -0,0 +1,8 @@
package pathmatch
// String makes pathmatch.Pattern fit the fmt.Stringer interface.
//
// String returns the (pre-compiled) pattern template.
func (receiver Pattern) String() string {
return receiver.template
}