Methods
(inner) Mount(param) → {function}
Koa Middleware that replaces ctx.path
with the value of
a matched route parameter before calling next()
and that
restores ctx.path
after the next middleware has finished
executing.
This middleware is included as a data-aware middleware by
Router
by default, unless disabled with an option.
Router#mount
uses this middleware by setting
{mount: "*"}
data on the route and by making sure that
the path ends with a catch-all param named *
.
Example
router.mount('/test', ctx => {
// ctx.path will not include the /test prefix
})
Parameters:
Name | Type | Description |
---|---|---|
param |
String | The named parameter to use for the new path. |
Returns:
The mount middleware
- Type
- function