SubRouter is a helper middleware that makes writing sub-routers easier.

If you register a sub-router under a key like "/admin/*", Goji's router will automatically set c.URLParams["*"] to the unmatched path suffix. This middleware will help you set the request URL's Path to this unmatched suffix, allowing you to write sub-routers with no knowledge of what routes the parent router matches.

Since Go's regular expressions do not allow you to create a capturing group named "*", SubRouter also accepts the string "_". For instance, to duplicate the semantics of the string pattern "/foo/*", you might use the regular expression "^/foo(?P<_>/.*)$".

This middleware is Match-aware: it will un-set any explicit routing information contained in the Goji context in order to prevent routing loops when using explicit routing with sub-routers. See the documentation for Mux.Router for more.

SubRouter is referenced in 13 repositories