2019-06-24 21:05:08 +00:00
|
|
|
package pathmatch_test
|
|
|
|
|
|
|
|
import (
|
2024-08-02 00:45:30 +00:00
|
|
|
"github.com/reiver/go-pathmatch"
|
2019-06-24 21:05:08 +00:00
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2019-06-24 21:20:49 +00:00
|
|
|
func ExamplePattern_String() {
|
2019-06-24 21:05:08 +00:00
|
|
|
|
|
|
|
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}
|
|
|
|
}
|