param(param, fn) {
    const { stack } = this;
    const params = this.paramNames;
    const middleware = function (ctx, next) {
      return fn.call(this, ctx.params[param], ctx, next);
    };

    middleware.param = param;

    const names = params.map(function (p) {
      return p.name;
    });

    const x = names.indexOf(param);
    if (x > -1) {
      // iterate through the stack, to figure out where to place the handler fn
      stack.some((fn, i) => {
        // param handlers are always first, so when we find an fn w/o a param property, stop here
        // if the param handler at this part of the stack comes after the one we are adding, stop here
        if (!fn.param || names.indexOf(fn.param) > x) {
          // inject this param handler right before the current item
          stack.splice(i, 0, middleware);
          return true; // then break the loop
        }
      });
    }

    return this;
  }
Run validations on route named parameters.

@example

```javascript
router
  .param('user', function (id, ctx, next) {
    ctx.user = users[id];
    if (!ctx.user) return ctx.status = 404;
    next();
  })
  .get('/users/:user', function (ctx, next) {
    ctx.body = ctx.user;
  });
```

@param {String} param
@param {Function} middleware
@returns {Layer}
@private