mirror of
https://github.com/arnaucube/raspberryGPIOhtmlserver.git
synced 2026-02-08 12:16:42 +01:00
servidor funciona, gpio desabilitat
This commit is contained in:
40
node_modules/connect/lib/middleware/vhost.js
generated
vendored
Executable file
40
node_modules/connect/lib/middleware/vhost.js
generated
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
|
||||
/*!
|
||||
* Connect - vhost
|
||||
* Copyright(c) 2010 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Vhost:
|
||||
*
|
||||
* Setup vhost for the given `hostname` and `server`.
|
||||
*
|
||||
* connect()
|
||||
* .use(connect.vhost('foo.com', fooApp))
|
||||
* .use(connect.vhost('bar.com', barApp))
|
||||
* .use(connect.vhost('*.com', mainApp))
|
||||
*
|
||||
* The `server` may be a Connect server or
|
||||
* a regular Node `http.Server`.
|
||||
*
|
||||
* @param {String} hostname
|
||||
* @param {Server} server
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function vhost(hostname, server){
|
||||
if (!hostname) throw new Error('vhost hostname required');
|
||||
if (!server) throw new Error('vhost server required');
|
||||
var regexp = new RegExp('^' + hostname.replace(/[^*\w]/g, '\\$&').replace(/[*]/g, '(?:.*?)') + '$', 'i');
|
||||
if (server.onvhost) server.onvhost(hostname);
|
||||
return function vhost(req, res, next){
|
||||
if (!req.headers.host) return next();
|
||||
var host = req.headers.host.split(':')[0];
|
||||
if (!regexp.test(host)) return next();
|
||||
if ('function' == typeof server) return server(req, res, next);
|
||||
server.emit('request', req, res);
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user