🔗 HTTP router based on radix trees.
Find a file
2023-07-10 11:41:37 +02:00
testdata Added Router type 2023-07-09 21:24:24 +02:00
.editorconfig Added tests and benchmarks 2023-07-09 17:46:17 +02:00
.gitignore Added tests and benchmarks 2023-07-09 17:46:17 +02:00
Benchmarks_test.go Added Router type 2023-07-09 21:24:24 +02:00
go.mod Updated dependencies 2023-07-10 11:41:37 +02:00
go.sum Updated dependencies 2023-07-10 11:41:37 +02:00
LICENSE Added basic routing 2023-07-09 12:42:33 +02:00
Parameter.go Added tests and benchmarks 2023-07-09 17:46:17 +02:00
README.md Added Router type 2023-07-09 21:24:24 +02:00
Router.go Added Router type 2023-07-09 21:24:24 +02:00
Router_test.go Added Router type 2023-07-09 21:24:24 +02:00
Tree.go Added tests and benchmarks 2023-07-09 17:46:17 +02:00
treeNode.go Added basic routing 2023-07-09 12:42:33 +02:00

router

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:

router := router.New[string]()

router.Add("GET", "/hello", "Hello")
router.Add("GET", "/world", "World")

Benchmarks

Requesting every single route in github.txt:

BenchmarkLookup-12           	   30147	     39105 ns/op	   19488 B/op	     337 allocs/op
BenchmarkLookupNoAlloc-12    	   85166	     14411 ns/op	       0 B/op	       0 allocs/op