Skip to content

Commit fb07e93

Browse files
authored
Move pathmux (zalando#361)
* import pathmux as an internal package * add pathmux section to the main project license
1 parent d7023a1 commit fb07e93

File tree

8 files changed

+916
-2
lines changed

8 files changed

+916
-2
lines changed

LICENSE

+36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
1+
Skipper is in general licensed under the following Apache Version 2.0 license with the exception
2+
of the pathmux subdirectory which is licensed under MIT license (see notice file below).
3+
14
Copyright 2015 Zalando SE
25

36
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
47

58
http://www.apache.org/licenses/LICENSE-2.0
69

710
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
11+
12+
13+
Notice file for pathmux/
14+
15+
The MIT License (MIT)
16+
17+
Copyright (c) 2014 Daniel Imfeld, 2015 Zalando SE
18+
19+
Permission is hereby granted, free of charge, to any person obtaining a copy
20+
of this software and associated documentation files (the "Software"), to deal
21+
in the Software without restriction, including without limitation the rights
22+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23+
copies of the Software, and to permit persons to whom the Software is
24+
furnished to do so, subject to the following conditions:
25+
26+
The above copyright notice and this permission notice shall be included in all
27+
copies or substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
36+
37+
38+
MODIFICATIONS TO pathmux/tree.go and pathmux/tree_test.go:
39+
40+
02.09.2015 - Exposed the internal tree implementation of http://godoc.org/github.com/dimfeld/httptreemux so that
41+
it can be used to look up arbitrary objects in a Patricia tree.
42+
43+
21.04.2016 - Enabled backtracking in the tree lookup.

pathmux/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Daniel Imfeld, 2015 Zalando SE
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

pathmux/Makefile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.PHONY: cpu mem
2+
3+
SOURCES = $(shell find . -name '*.go')
4+
5+
default: build
6+
7+
build: $(SOURCES)
8+
go build
9+
10+
install: $(SOURCES)
11+
go install
12+
13+
check: build
14+
go test -race
15+
16+
shortcheck: build
17+
go test -test.short -run ^Test
18+
19+
bench: build
20+
go test -cpuprofile cpu.out -memprofile mem.out -bench .
21+
22+
cpu:
23+
go tool pprof -top cpu.out # Run 'make bench' to generate profile.
24+
25+
mem:
26+
go tool pprof -top mem.out # Run 'make bench' to generate profile.
27+
28+
gencover: build
29+
go test -coverprofile cover.out
30+
31+
cover: gencover
32+
go tool cover -func cover.out
33+
34+
showcover: gencover
35+
go tool cover -html cover.out
36+
37+
fmt: $(SOURCES)
38+
gofmt -w -s ./*.go
39+
40+
vet: $(SOURCES)
41+
go vet
42+
43+
check-ineffassign: $(SOURCES)
44+
ineffassign .
45+
46+
check-spell: $(SOURCES) README.md Makefile
47+
misspell -error README.md Makefile *.go
48+
49+
lint: $(SOURCES)
50+
golint -set_exit_status -min_confidence 0.9
51+
52+
precommit: build check fmt cover vet check-ineffassign check-spell lint
53+
# ok

pathmux/README.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[![GoDoc](https://godoc.org/github.com/zalando/pathmux?status.svg)](https://godoc.org/github.com/zalando/pathmux)
2+
[![Go Report Card](https://goreportcard.com/badge/github.com/zalando/pathmux)](https://goreportcard.com/report/github.com/zalando/pathmux)
3+
[![Go Cover](https://gocover.io/_badge/github.com/zalando/pathmux)](https://gocover.io/github.com/zalando/pathmux)
4+
5+
# Pathmux: tree lookup with wildcard matching
6+
7+
Pathmux is a package that implements an effective tree lookup with wildcard matching. It is a fork of the awesome [httptreemux](https://github.com/dimfeld/httptreemux). This fork makes visible the interface of the internal tree lookup implementation of the original httptreemux package, and with the HTTP-related wrapper code stripped away.
8+
9+
In addition to having the original httptreemux logic, pathmux offers one small feature: backtracking. This means that when a
10+
path is matched, it is possible to instruct the lookup not to return the found object when other, custom
11+
conditions are not met, but instead continue the lookup by backtracking from the current point in the tree.
12+
13+
Pathmux is used by [Skipper](https://github.com/zalando/skipper), an extensible HTTP routing server used in production at Zalando.
14+
15+
### When to Use pathmux Instead of httptreemux
16+
17+
Almost never, except when:
18+
19+
- you want to store a large number of **custom** objects in an effective lookup tree, keyed by path values
20+
- you want to use the backtracking feature to refine the evaluation of wildcard matching with custom logic
21+
22+
### Installation
23+
24+
```
25+
go get github.com/zalando/pathmux
26+
```
27+
28+
Pathmux is 'go get compatible'. The master head is always stable (at least by intent), and it doesn't use any vendoring itself. However, we strongly recommend that you use vendoring in the final, importing, executable package.
29+
30+
### Documentation
31+
32+
You can find detailed package documentation [here](https://godoc.org/github.com/zalando/pathmux).
33+
34+
### Working with the Code
35+
36+
While it is enough to use `go get` to import the package, when modifying the code, it is worth cherry-picking from the tasks in the provided simple Makefile.
37+
38+
### Contributing
39+
See our detailed [contribution guidelines](https://github.com/zalando/pathmux/blob/master/CONTRIBUTING.md). If you plan on contributing to the current repository, please make sure:
40+
41+
1. to run the precommit checks:
42+
43+
```
44+
make precommit
45+
```
46+
47+
Please fix all reported errors and please make sure that the overall test coverage is not decreased. (Please
48+
feel free to provide tests for the missing spots :))
49+
50+
2. compare the performance of the new version to the current master, and avoid degradations:
51+
52+
```
53+
make bench
54+
```
55+
56+
(Comparison currently can happen only by running the same `make bench` on the master branch. Automating the comparison would be a nice contribution.)
57+
58+
### License
59+
60+
Copyright (c) 2014 Daniel Imfeld, 2015 Zalando SE
61+
62+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
63+
64+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
65+
66+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)