Routing
Namespaces
Group route paths, route names, controller metadata, and view lookup.
Use Namespace for admin-style areas
Namespace prefixes path, route name, and namespace metadata:
router.Namespace("admin", func(admin *lazyroutes.Scope) {
admin.Resources(adminposts.New)
})
That produces routes like:
admin_posts GET /admin/posts
admin_post GET /admin/posts/{post_id}
The route metadata records:
Namespace: "admin"
Place namespaced views under the namespace
Namespaced controller views live in matching directories:
app/views/admin/posts/index.html.tpl
app/views/admin/posts/show.html.tpl
GoLazy does not fall back to app/views/posts/index.html.tpl for namespaced
controller views. Shared fallback views can still live under app/views/app.
Prefix only paths
Use Path when only the URL path should be nested:
account := router.Path("accounts/{account_id}")
account.Get(
"/posts/{post_id}",
posts.New,
(*posts.PostsController).Show,
)
That produces:
/accounts/{account_id}/posts/{post_id}
Prefix only route names
Use As when only helper names should be nested:
router.Path("accounts/{account_id}").As("account").Get(
"/posts/{post_id}",
posts.New,
(*posts.PostsController).Show,
)
That route can use an account_post style name while keeping the controller
namespace unchanged.