23 lines
543 B
Markdown
Raw Normal View History

2023-07-09 10:21:32 +00:00
# router
2023-07-09 17:46:17 +02:00
HTTP router based on radix trees.
2023-07-09 21:24:24 +02:00
## 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")
```
2023-07-09 17:46:17 +02:00
## Benchmarks
2023-07-09 21:24:24 +02:00
Requesting every single route in [github.txt](testdata/github.txt):
2023-07-09 17:46:17 +02:00
```
2023-07-09 21:24:24 +02:00
BenchmarkLookup-12 30147 39105 ns/op 19488 B/op 337 allocs/op
BenchmarkLookupNoAlloc-12 85166 14411 ns/op 0 B/op 0 allocs/op
2023-07-09 17:46:17 +02:00
```