https://github.com/yudai/pmatcher
Simple path matching library for Go
https://github.com/yudai/pmatcher
Last synced: 8 months ago
JSON representation
Simple path matching library for Go
- Host: GitHub
- URL: https://github.com/yudai/pmatcher
- Owner: yudai
- License: mit
- Created: 2016-03-01T23:58:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-02T00:11:56.000Z (over 9 years ago)
- Last Synced: 2024-12-28T13:18:09.912Z (9 months ago)
- Language: Go
- Homepage:
- Size: 1010 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Path Matcher
## Usage
```sh
go get github.com:yudai/pmatcher
``````go
import "github.com:yudai/pmatcher/"matcher := pmatcher.New()
matcher.Add("/foo/bar")
matcher.Add("/foo/:p1/:p2")
matcher.Add("/foo/bar/baz")
matcher.Add("/baz/:p1")
matcher.Add("/baz/one")
matcher.Add("/baz/:p1/two")
matcher.Add("/baz/:p2/three")matched, pattern, params := matcher.Match("/foo/some/thing")
// matched => true
// pattern => "/foo/:p1/:p2"
// params => map[string]string{"p1": "some", "p2": "thing"}
```