Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the documentation of chi.Router #714

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion chi.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,25 @@ type Router interface {
With(middlewares ...func(http.Handler) http.Handler) Router

// Group adds a new inline-Router along the current routing
// path, with a fresh middleware stack for the inline-Router.
// path, with a fresh middleware stack for the inline-router.
//
// The "fresh" middleware stack will implicitly contain all
// of the middlewares previously applied to the parent router,
// and any new ones added to this stack will NOT propagate to
// the parent or any other routers created via Group.
//
// Conversely, Group is NOT suited to obtain a new sub-router
// without any middlewares if the parent has already had any
// middlewares applied to it. In order to have sub-routers
// with fully separate stacks of middlewares, it is recommended
// to NOT apply any middlewares at the parent level and instead
// ONLY apply middlewares to sub-routers created via Group.
//
// Furthermore, defining routes on a sub-router obtained via
// Group WILL count towards the parent router having any routes
// defined, which makes it impossible to add any middlewares to
// the parent (but not to sub-routers obtained by calling Group
// on it) afterwards.
Group(fn func(r Router)) Router

// Route mounts a sub-Router along a `pattern`` string.
Expand Down