1.1.0 • Published 9 years ago

predirect v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

predirect

Simple http redirect method

Build Status downloads

Usage

var redirect = require('predirect');
var http = require('http');

http.createServer(function (req, res) {

  redirect(req, res, 'https://github.com');

}).listen(3333);

or with currying:

var predirect = require('predirect');
var http = require('http');

http.createServer(function (req, res) {

  var redirect = predirect(req, res);

  // ...

  redirect('https://github.com');

}).listen(3333);

API

redirect(req, res, url, text)

Redirect to url and respond with text if the request method isn't HEAD.

text gets parsed by util.format and defaults to -> %s.

If you only pass req and res, this will return a function you can then pass url and text to.

redirect(ctx, url, text)

Pass a context with .req and .res, instead of two separate arguments.

Installation

With npm do:

$ npm install predirect

License

(MIT)

1.1.0

9 years ago

1.0.0

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago