You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.
I detected two kinds of subrouting that we may want to support:
Convenience setup for path and name prefix: when defining several routes that share a path or name prefix, it is nice to have a way to define the shared prefix once, then define the remaining based on that "subroute". It's avoids repeating yourself and also makes a bit easier to refactor a route setup;
These are somewhat related. The first one is simply "nice to have"; the second is not a so common use case, but why not? In any case, the first can be used by the second when mounting a foreign router in a given path. The docs for Mount() illustrate it better:
// Mount imports all routes from the given router into this one.//// Combined with Sub() and Name(), it is possible to submount a router// defined in a different package using pattern and name prefixes://// r := New()// s := r.Sub("/admin").Name("admin:").Mount(admin.Router)func (r*Router) Mount(router*Router) *Router {
These two kinds of subrouting require the three router methods exemplified in the docs above: Sub() (which creates a subrouter for a pattern prefix), Name() (sets a name prefix for the routes), and Mount() (imports routes defined elsewhere).
Given this initial draft, I invite you to share your thoughts about the subject.
The text was updated successfully, but these errors were encountered:
I detected two kinds of subrouting that we may want to support:
These are somewhat related. The first one is simply "nice to have"; the second is not a so common use case, but why not? In any case, the first can be used by the second when mounting a foreign router in a given path. The docs for
Mount()
illustrate it better:These two kinds of subrouting require the three router methods exemplified in the docs above:
Sub()
(which creates a subrouter for a pattern prefix),Name()
(sets a name prefix for the routes), andMount()
(imports routes defined elsewhere).Given this initial draft, I invite you to share your thoughts about the subject.
The text was updated successfully, but these errors were encountered: