Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add sample

  • Loading branch information...
commit d337d69d2279826c44fe22c03608b70290502216 1 parent 11786db
@naholyr naholyr authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 sample.js
View
20 sample.js
@@ -0,0 +1,20 @@
+var http = require('http');
+var express = require('express');
+var virtualhost = require('./virtualhost');
+
+// Compatible with standard handler
+var handler1 = function (req, res) {
+ res.end('handler1');
+};
+
+// Compatible with express 3.x
+var handler2 = express().get('/', function (req, res) {
+ res.end('handler2 (' + req.virtualhost.match[1] + ')');
+});
+
+var apps = {
+ "sub.domain.tld": handler1,
+ "main": { pattern: /^(www\.)?domain\.tld$/, handler: handler2 }
+};
+
+http.createServer(virtualhost(apps)).listen(8080);
Please sign in to comment.
Something went wrong with that request. Please try again.