0.0.0 • Published 10 years ago

sw-redirect v0.0.0

Weekly downloads
3
License
WTFPL
Repository
github
Last release
10 years ago

sw-redirect

Convenience middleware for HTTP 3xx redirects. Adds a .redirect() method to the res object which sends a redirect to the chosen URL.

Install

npm install sw-redirect

Example

var redirect = require('sw-redirect');

// With express
app.use(redirect);

// or use as inline middleware
app.get('/example/moved', redirect, function(req, res) {
	res.redirect('/another/page', 307);
});

API

res.redirect(url, [code])

  • url - Destination URL
  • code - Status code, optional, defaults to 303