pathmatch.Pattern.String()
parent
4b0308c64e
commit
64422ea7ec
|
@ -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}
|
||||
}
|
|
@ -32,6 +32,7 @@ import (
|
|||
// }
|
||||
type Pattern struct {
|
||||
mutex sync.RWMutex
|
||||
template string
|
||||
bits []string
|
||||
names []string
|
||||
namesSet map[string]struct{}
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue