dox-foundation-demo node_modules/express/lib/router/index.js

Route

declaration
Route

    Description

    Module dependencies.

    Source

    var Route = require('./route')
      , utils = require('../utils')
      , methods = require('methods')
      , debug = require('debug')('express:router')
      , parse = require('connect').utils.parseUrl;

    param

    method
    Router.prototype.param()
    • @param: {String,Function}name
    • @param: {Function}fn
    • @return: {Router}for chaining

    Description

    Register a param callback fn for the given name.

    Source

    Router.prototype.param = function(name, fn){
      // param logic
      if ('function' == typeof name) {
        this._params.push(name);
        return;
      }
    
      // apply param functions
      var params = this._params
        , len = params.length
        , ret;
    
      for (var i = 0; i < len; ++i) {
        if (ret = params[i](name, fn)) {
          fn = ret;
        }
      }
    
      // ensure we end up with a
      // middleware function
      if ('function' != typeof fn) {
        throw new Error('invalid param() call for ' + name + ', got ' + fn);
      }
    
      (this.params[name] = this.params[name] || []).push(fn);
      return this;
    };