Bind registers one or multiple middleware handlers to the current group.
BindFunc registers one or multiple middleware functions to the current group.
The registered middleware functions are "anonymous" and with default priority, aka. executes in the order they were registered.
If you need to specify a named middleware (ex. so that it can be removed) or middleware with custom exec prirority, use [RouterGroup.Bind] method.
Rest
...middlewareFuncs: ((e) => void)[]Group creates and register a new child Group into the current one with the specified prefix.
The prefix follows the standard Go net/http ServeMux pattern format ("[HOST]/[PATH]") and will be concatenated recursively into the final route path, meaning that only the root level group could have HOST as part of the prefix.
Returns the newly created group to allow chaining and registering sub-routes and group specific middlewares.
HasRoute checks whether the specified route pattern (method + path) is registered in the current group or its children.
This could be useful to conditionally register and checks for routes in order prevent panic on duplicated routes.
Note that routes with anonymous and named wildcard placeholder are treated as equal, aka. "GET /abc/" is considered the same as "GET /abc/{something...}".
Route registers a single route into the current group.
Note that the final route path will be the concatenation of all parent groups prefixes + the route path. The path follows the standard Go net/http ServeMux format ("[HOST]/[PATH]"), meaning that only a top level group route could have HOST as part of the prefix.
Returns the newly created route to allow attaching route-only middlewares.
Unbind removes one or more middlewares with the specified id(s) from the current group and its children (if any).
Anonymous middlewares are not removable, aka. this method does nothing if the middleware id is an empty string.
Rest
...middlewareIds: string[]Generated using TypeDoc
Router defines a thin wrapper around the standard Go [http.ServeMux] by adding support for routing sub-groups, middlewares and other common utils.
Example: