2019-06-24 21:05:08 +00:00
|
|
|
package pathmatch_test
|
|
|
|
|
|
|
|
import (
|
2023-10-01 04:49:20 +00:00
|
|
|
"sourcecode.social/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}
|
|
|
|
}
|