Skip to content
Myr

Added req.param()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 7897460 · Browse files · 3 files+37 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+37 added−1 removed

  • tests:+16 added−0 removed
  • other:+21 added−1 removed

3 files+37 added−1 removed

modified:lib/express/request.js+10 added
modified:lib/express/server.js+11 added-1 removed
8 unmodified lines
9 * Module dependencies.10 */1112var sys = require('sys'),13 url = require('url'),14 connect = require('connect'),15 queryString = require('querystring'),16 router = require('connect/middleware/router');1718/**19 * Initialize a new `Server` with optional `middleware`.
7 unmodified lines
27 this.config = {};28 this.settings = {};29 connect.Server.call(this, middleware || []);3029 // Expose app to extensions31 // Expose objects to each other32 this.use('/', function(req, res, next){33 req.params = req.params || {};34 req.params.get = {};35 res.headers = {};36 req.app = res.app = self;37 req.res = res;38 res.req = req;39 // Assign req.params.get40 if (req.url.indexOf('?') > 0) {41 // TODO: consider simple substr to increase performance42 var query = url.parse(req.url).query;43 req.params.get = queryString.parse(query);44 }45 next();46 });4748 // Use router, expose as app.get(), etc
110 unmodified lines
modified:test/request.test.js+16 added