Added Router type
This commit is contained in:
17
README.md
17
README.md
@ -2,11 +2,22 @@
|
||||
|
||||
HTTP router based on radix trees.
|
||||
|
||||
## Example
|
||||
|
||||
We can save any type of data inside the router. Here is an example storing strings for each route:
|
||||
|
||||
```go
|
||||
router := router.New[string]()
|
||||
|
||||
router.Add("GET", "/hello", "Hello")
|
||||
router.Add("GET", "/world", "World")
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Loading and requesting every single route in [github.txt](testdata/github.txt):
|
||||
Requesting every single route in [github.txt](testdata/github.txt):
|
||||
|
||||
```
|
||||
BenchmarkLookup-12 50715 23207 ns/op 11649 B/op 204 allocs/op
|
||||
BenchmarkLookupNoAlloc-12 148033 7993 ns/op 0 B/op 0 allocs/op
|
||||
BenchmarkLookup-12 30147 39105 ns/op 19488 B/op 337 allocs/op
|
||||
BenchmarkLookupNoAlloc-12 85166 14411 ns/op 0 B/op 0 allocs/op
|
||||
```
|
Reference in New Issue
Block a user