Skip to content
Myr

Added app.redirect(key, url)

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 2d31f0d · Browse files · 3 files+17 added−6 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+17 added−6 removed

  • tests:+1 added−3 removed
  • other:+16 added−3 removed

3 files+17 added−6 removed

modified:lib/express/response.js+1 added-3 removed
modified:lib/express/server.js+15 added
25 unmodified lines
26var Server = exports = module.exports = function Server(middleware){27 var self = this;28 this.config = {};29 this.settings = {};30 this.redirects = {};31 connect.Server.call(this, middleware || []);3233 // Expose objects to each other34 this.use('/', function(req, res, next){
124 unmodified lines
159 return this.set(setting, false);160};161162/**163 * Redirect `key` to `url`.164 *165 * @param {String} key166 * @param {String} url167 * @return {Server} for chaining168 * @api public169 */170171Server.prototype.redirect = function(key, url){172 this.redirects[key] = url;173 return this;174};175176/**177 * Disable `setting`.178 *179 * @param {String} setting180 * @return {Server} for chaining
18 unmodified lines
modified:test/response.test.js+1 added-3 removed
96 unmodified lines
97 app2 = express.createServer();98 99 app2.set('home', '/blog');100101 app2.redirect = {102 google: 'http://google.com'103 };101 app2.redirect('google', 'http://google.com');102103 app.get('/', function(req, res){104 res.redirect('http://google.com', 301);105 });
56 unmodified lines