@param {IncomingMessage} req
@param {ServerResponse} res
@param {Function} next

@returns {undefined}
508361
function notFoundRequestHandler( req, res, next ) {
  var err = new Error( 'Not Found' )

  err.statusCode = 404
  next( err )
}
338581
function post (req, res, next) {
    var prop = pluralize.singular(req.params.resource)
    req.body[prop + 'Id'] = utils.toNative(req.params.id)
    req.url = '/' + req.params.nested
    next()
  }
50476
function (req, res, next) {
            if (options.forceAuthorize) {
                return next();
            }
            var userId = req.oauth2.user.id;
            var clientId = req.oauth2.client.id;
            var scope = req.oauth2.req.scope;
            models.Permissions.isAuthorized(clientId, userId, scope,
                function (err, authorized) {
                    if (err) {
                        return next(err);
                    } else if (authorized) {
                        req.oauth2.res = {};
                        req.oauth2.res.allow = true;
                        server._respond(req.oauth2, res, function (err) {
                            if (err) {
                                return next(err);
                            }
                            return next(new AuthorizationError('Unsupported response type: '
                                + req.oauth2.req.type, 'unsupported_response_type'));
                        });
                    } else {
                        next();
                    }
                });
        }
116018
function authorize(req, res, next) {
  const role = findRoleFromRequest(
    req,
    options.roleSearchPath,
    options.defaultRole,
    options.decodedObjectName
  );

  if (req.originalUrl === '/') {
    return next();
  }

  const policy = options.policies.get(role);

  if (!policy) {
    return res.status(403).json({
      status: 'Access denied',
      success: false,
      message: `REQUIRED: Policy for role ${role} is not defined`
    });
  }

  const permission = findPermissionForRoute(
    req.originalUrl,
    req.method,
    options.baseUrl,
    policy
  );

  if (!permission) {
    if (typeof options.denyCallback === 'function') {
      return options.denyCallback(res);
    }
    return res.status(403).json(deny(options.customMessage, options.response));
  }

  return checkIfHasAccess(
    req.method,
    res,
    next,
    permission,
    options.customMessage,
    options.response,
    options.denyCallback
  );
}
794207
function get(req, res, next) {
  var params = {
    appId: req.params.projectid || req.params.id
  };

  forms.getAppFormsForApp(_.extend(req.connectionOptions, params), formsResultHandlers(constants.resultTypes.formProjects, req, next));
}
880368
function(req, res, next) {
        var initialTime = 0,
            receivedReqTime = new Date().getTime();

        req.requestDelay =  receivedReqTime - initialTime;
        var url = req.body.url;

        request.get(url, function (error, response, body) {
            if (!error && response.statusCode == 200) {
                req.rawOntology = body.toString().replace(/(&)([a-z0-9]+)(;)/gi, '$2:');
                next();
            }
        });
    }
214310
function show(req, res, next) {
  db.users.find(req.params.user, function(err, user) {
    if(err) { return next(err); }
    res.json(user);
  });
}
405752
function (req, res, next) {
                // Delayed resolution of the isLoggedIn middleware.
                if (server.registry.has('localUserMiddleware')) {
                    const middleware = server.registry.get('localUserMiddleware');
                    middleware.isLoggedInMiddleware()(req, res, next);
                } else {
                    next(new restifyErrors.ForbiddenError(`Server configuration error, 'localUserMiddleware' not found.`));
                }
            }
516671
function queryParser( req, res, next ) {
	if ( !req.query ) {
		var val = parseUrl( req ).query;
		req.query = queryparse( val );
	}
	next();
}
562673
function(err, req, res, next) {
    err.message = err.message || 'Internal Server Error';
    err.code = err.code || res.code || 500;
    if (!_.isNumber(err.code)) {
      err.code = 500;
    }

    try {
      err.line = err.stack.split('\n')[1].match(/\(.+\)/)[0];
    } catch (e) {
      err.line = null;
    }

    var envelope = {
      meta: {
        code: err.code,
        error: {
          code: err.code,
          message: err.message,
          line: err.line
        }
      },
      data: err.message
    };

    // Set code and data
    res.code = err.code;
    res.data = envelope;

    return next();
  }
1103202
function catchClientError(req, res, next) {
  const { end } = res;

  res.end = function() {
    // console.log(`Catch client response : ${req.url} ${res.statusCode}`);
    const errorRoute = Route
      .routes('err')
      .filter((obj) => {
        return obj.extra.status === res.statusCode && obj.route !== req.url;
      });

    if(errorRoute.length > 0 && !isRedirect) {
      return redirect(errorRoute[0], req, res, next);
    }

    isRedirect = false;
    end.apply(res, arguments);
  };

  next();
}
1327841
function submissions(req, res, next) {
  var params = {
    formId: req.params.id
  };

  logger.debug("Middleware: form submissions: ", {params: params});

  forms.getSubmissions(req.connectionOptions, params, function(err, getSubmissionResponse) {
    if (err) {
      logger.error("Middleware: form submissions ", {error: err});
    }
    getSubmissionResponse = getSubmissionResponse || {};
    req.appformsResultPayload = {
      data: getSubmissionResponse.submissions,
      type: constants.resultTypes.submissions
    };

    next(err);
  });
}
1124770
function reqres(res, req) {
    if (req && req._headers) {
        throw new Error('Received response object where request object was expected');
    }
    this.res = res;
    this.req = req;
    if (res) {
        if (res.$ && res.$.data) {
            this.data = res.$.data;
        }
        else {
            this.data = { error: null };
            if (!res.$) {
                res.$ = this;
            }
        }
    }
}
1303500
function handler(req, res, next) {
    next = next || send

    if (pending) return pending.once('ready', function(err) {
      if (err) return next(err)
      return handler(req, res, next)
    })

    if (prevError) return next(prevError)

    res.setHeader('content-type', 'text/css')
    return next(null, buffer)

    function send(err, body) {
      if (err) return res.emit(err)
      res.end(body)
    }
  }
269684
function (req, res, next) {
      if (req.query.return) {
        req.session.oauth2return = req.query.return;
      }
      next();
    }
1206358
function get(req, res) {
  var ptn = '' + req.args[0]
    , keys = this.pattern.filter(ptn, this.conf.getKeys())
    , list = []
    , i
    , k;
  for(i = 0;i < keys.length;i++) {
    k = keys[i];
    list.push(k, '' + this.conf.get(k));
  }
  res.send(null, list);
}
1261650
function get(req, res, next) {
  var params = {
    _id: req.params.id
  };

  logger.debug("Middleware Submissions Get ", {params: params});

  forms.getSubmission(req.connectionOptions, params, submissionsHandler(constants.resultTypes.submissions, req, next));
}