Added trailing slash for static routes

This commit is contained in:
Eduard Urbach 2024-03-13 13:04:03 +01:00
parent 0323126f2c
commit a7d64037a7
Signed by: eduard
GPG key ID: 49226B848C78F6C8
8 changed files with 119 additions and 96 deletions

View file

@ -4,14 +4,15 @@ import (
"testing"
"git.akyoto.dev/go/router"
"git.akyoto.dev/go/router/testdata"
)
func BenchmarkBlog(b *testing.B) {
routes := loadRoutes("testdata/blog.txt")
routes := testdata.Routes("testdata/blog.txt")
r := router.New[string]()
for _, route := range routes {
r.Add(route.method, route.path, "")
r.Add(route.Method, route.Path, "")
}
b.Run("Len1-Param0", func(b *testing.B) {
@ -28,11 +29,11 @@ func BenchmarkBlog(b *testing.B) {
}
func BenchmarkGitHub(b *testing.B) {
routes := loadRoutes("testdata/github.txt")
routes := testdata.Routes("testdata/github.txt")
r := router.New[string]()
for _, route := range routes {
r.Add(route.method, route.path, "")
r.Add(route.Method, route.Path, "")
}
b.Run("Len7-Param0", func(b *testing.B) {
@ -53,3 +54,6 @@ func BenchmarkGitHub(b *testing.B) {
}
})
}
// noop serves as an empty addParameter function.
func noop(string, string) {}