TestTreeTrailingSlashRedirect() — gin Function Reference
Architecture documentation for the TestTreeTrailingSlashRedirect() function in tree_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 0eb870f4_381f_fe31_be50_10a3af90c78b["TestTreeTrailingSlashRedirect()"] 7d17d111_6d55_8539_e0ed_b32eea9e5ef6["catchPanic()"] 0eb870f4_381f_fe31_be50_10a3af90c78b -->|calls| 7d17d111_6d55_8539_e0ed_b32eea9e5ef6 6dab8d3e_0986_1500_b06f_6323ea7ce91a["fakeHandler()"] 0eb870f4_381f_fe31_be50_10a3af90c78b -->|calls| 6dab8d3e_0986_1500_b06f_6323ea7ce91a 3890ddc0_c7b9_b8d1_7ac9_5fc2030c1b8e["getSkippedNodes()"] 0eb870f4_381f_fe31_be50_10a3af90c78b -->|calls| 3890ddc0_c7b9_b8d1_7ac9_5fc2030c1b8e style 0eb870f4_381f_fe31_be50_10a3af90c78b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tree_test.go lines 570–674
func TestTreeTrailingSlashRedirect(t *testing.T) {
tree := &node{}
routes := [...]string{
"/hi",
"/b/",
"/search/:query",
"/cmd/:tool/",
"/src/*filepath",
"/x",
"/x/y",
"/y/",
"/y/z",
"/0/:id",
"/0/:id/1",
"/1/:id/",
"/1/:id/2",
"/aa",
"/a/",
"/admin",
"/admin/:category",
"/admin/:category/:page",
"/doc",
"/doc/go_faq.html",
"/doc/go1.html",
"/no/a",
"/no/b",
"/api/:page/:name",
"/api/hello/:name/bar/",
"/api/bar/:name",
"/api/baz/foo",
"/api/baz/foo/bar",
"/blog/:p",
"/posts/:b/:c",
"/posts/b/:c/d/",
"/vendor/:x/*y",
}
for _, route := range routes {
recv := catchPanic(func() {
tree.addRoute(route, fakeHandler(route))
})
if recv != nil {
t.Fatalf("panic inserting route '%s': %v", route, recv)
}
}
tsrRoutes := [...]string{
"/hi/",
"/b",
"/search/gopher/",
"/cmd/vet",
"/src",
"/x/",
"/y",
"/0/go/",
"/1/go",
"/a",
"/admin/",
"/admin/config/",
"/admin/config/permissions/",
"/doc/",
"/admin/static/",
"/admin/cfg/",
"/admin/cfg/users/",
"/api/hello/x/bar",
"/api/baz/foo/",
"/api/baz/bax/",
"/api/bar/huh/",
"/api/baz/foo/bar/",
"/api/world/abc/",
"/blog/pp/",
"/posts/b/c/d",
"/vendor/x",
}
for _, route := range tsrRoutes {
value := tree.getValue(route, nil, getSkippedNodes(), false)
if value.handlers != nil {
t.Fatalf("non-nil handler for TSR route '%s", route)
} else if !value.tsr {
t.Errorf("expected TSR recommendation for route '%s'", route)
}
}
noTsrRoutes := [...]string{
"/",
"/no",
"/no/",
"/_",
"/_/",
"/api",
"/api/",
"/api/hello/x/foo",
"/api/baz/foo/bad",
"/foo/p/p",
}
for _, route := range noTsrRoutes {
value := tree.getValue(route, nil, getSkippedNodes(), false)
if value.handlers != nil {
t.Fatalf("non-nil handler for No-TSR route '%s", route)
} else if value.tsr {
t.Errorf("expected no TSR recommendation for route '%s'", route)
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does TestTreeTrailingSlashRedirect() do?
TestTreeTrailingSlashRedirect() is a function in the gin codebase.
What does TestTreeTrailingSlashRedirect() call?
TestTreeTrailingSlashRedirect() calls 3 function(s): catchPanic, fakeHandler, getSkippedNodes.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free