diff options
| author | Shulhan <ms@kilabit.info> | 2024-06-08 14:49:13 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-06-08 15:44:47 +0700 |
| commit | c8b408fc32fcaba43f69bd494305c52cbdeb06c6 (patch) | |
| tree | 74c40a06fe12c70ee7f6598816f9ad2bbf7c18e4 /lib/path/route_example_test.go | |
| parent | 85dffe4cb596ba8d5131c07f8993c6158184d988 (diff) | |
| download | pakakeh.go-c8b408fc32fcaba43f69bd494305c52cbdeb06c6.tar.xz | |
lib/path: add method Path to Route
Unlike String method that may return the key's name in returned path,
the Path method return the path with all the keys has been substituted
with values, even if its empty.
Diffstat (limited to 'lib/path/route_example_test.go')
| -rw-r--r-- | lib/path/route_example_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/path/route_example_test.go b/lib/path/route_example_test.go index 93799773..3baa730f 100644 --- a/lib/path/route_example_test.go +++ b/lib/path/route_example_test.go @@ -94,6 +94,31 @@ func ExampleRoute_Parse() { // false map[] } +func ExampleRoute_Path() { + var ( + rute *libpath.Route + err error + ) + + rute, err = libpath.NewRoute(`/:user/:repo`) + if err != nil { + log.Fatal(err) + } + + fmt.Println(rute.Path()) + + rute.Set(`user`, `shuLhan`) + fmt.Println(rute.Path()) + + rute.Set(`repo`, `pakakeh.go`) + fmt.Println(rute.Path()) + + // Output: + // // + // /shuLhan/ + // /shuLhan/pakakeh.go +} + func ExampleRoute_Set() { var ( rute *libpath.Route |
