Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add function comments and fixed demo options.

  • Loading branch information...
commit 1be2883f48da6bafc33a5c725862beaa83d062a9 1 parent 14d56fd
@fengmk2 fengmk2 authored
Showing with 15 additions and 2 deletions.
  1. +2 −0  .npmignore
  2. +2 −1  README.md
  3. +1 −1  example/demo.js
  4. +10 −0 lib/onehost.js
View
2  .npmignore
@@ -0,0 +1,2 @@
+test/
+Makefile
View
3  README.md
@@ -10,7 +10,8 @@ var onehost = require('onehost');
var app = connect(
onehost({
- toHost: 'localhost.cnodejs.org'
+ host: 'localhost.cnodejs.org',
+ // exclude: 'dev.cnodejs.org',
}),
function (req, res) {
res.end(JSON.stringify({headers: req.headers, url: req.url}));
View
2  example/demo.js
@@ -3,7 +3,7 @@ var onehost = require('../');
var app = connect(
onehost({
- toHost: 'localhost'
+ host: 'localhost'
}),
function (req, res) {
res.end(JSON.stringify({headers: req.headers, url: req.url}));
View
10 lib/onehost.js
@@ -11,6 +11,16 @@
* Module dependencies.
*/
+/**
+ * One host binding middleware.
+ *
+ * @param {Object} options
+ * - {String} host, which host should be binding.
+ * - {Array|String} [exclude], ignore hosts, they won't be handle.
+ * e.g.: 'abc.com' or `['abc.com', 'dec.com']`, default is `[]`.
+ * - {String} [protocol], http or https, default is http.
+ * @return {Function(req, res, next)} middleware function.
+ */
module.exports = function onehost(options) {
var EXCLUDE_HOST_RE = null;
options = options || {};
Please sign in to comment.
Something went wrong with that request. Please try again.