feat: add rest.WithPrefix to support route prefix (#1194)

This commit is contained in:
Kevin Wan
2021-11-01 20:15:10 +08:00
committed by GitHub
parent 7e3fe77e7b
commit 91b10bd3b9
2 changed files with 36 additions and 0 deletions

View File

@@ -213,6 +213,25 @@ func TestMultiMiddlewares(t *testing.T) {
}, m)
}
func TestWithPrefix(t *testing.T) {
fr := featuredRoutes{
routes: []Route{
{
Path: "/hello",
},
{
Path: "/world",
},
},
}
WithPrefix("/api")(&fr)
var vals []string
for _, r := range fr.routes {
vals = append(vals, r.Path)
}
assert.EqualValues(t, []string{"/api/hello", "/api/world"}, vals)
}
func TestWithPriority(t *testing.T) {
var fr featuredRoutes
WithPriority()(&fr)