Comparing version 0.0.1 to 0.0.2
29
app.js
@@ -10,4 +10,29 @@ var fileServer = require("./index"); | ||
}; | ||
var transRules = { | ||
"7676": { | ||
//目标服务器的ip和端口,域名也可,但注意不要被host了 | ||
targetServer: { | ||
"host": "10.46.133.242",//gcrm | ||
"port": "8101" | ||
// "host": "172.21.206.166",//gcrm | ||
// "port": "8080" | ||
// "host": "172.21.206.84",//gcrm | ||
// "port": "8081" | ||
}, | ||
//特殊请求转发,可选配置,内部的host、port和attachHeaders为可选参数 | ||
regExpPath: { | ||
"gcrm/" : { | ||
path : "gcrm/" | ||
} | ||
// , | ||
// "vendor/": { | ||
// "host": "127.0.0.1", | ||
// "port": "7777", | ||
// "path": "vendor/" | ||
// } | ||
} | ||
}, | ||
"ajaxOnly": false | ||
}; | ||
fileServer.start(serverSettings); | ||
fileServer.start(serverSettings, transRules); |
@@ -35,3 +35,3 @@ var http = require("http"); | ||
module.exports = { | ||
start: function (params) { | ||
start: function (params, rules) { | ||
var servers = params || {}; | ||
@@ -52,3 +52,3 @@ var serverList = []; | ||
if (typeof transpond === "function") { | ||
transpond(req, res); | ||
transpond(req, res, rules); | ||
} | ||
@@ -59,7 +59,7 @@ return false; | ||
var pathHandle = function (realPath) { | ||
console.log(realPath); | ||
// console.log(realPath); | ||
fs.stat(realPath, function (err, stats) { | ||
if (err) { | ||
if (typeof transpond === "function") { | ||
transpond(req, res); | ||
transpond(req, res, rules); | ||
} else { | ||
@@ -66,0 +66,0 @@ //console.log(req.url + " 404"); |
{ | ||
"name": "gulp-bird", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "bird-v2", | ||
@@ -5,0 +5,0 @@ "keywords": ["bird","gulp"], |
@@ -5,31 +5,6 @@ var http = require("http"); | ||
module.exports = function () { | ||
this.transpond = function (req, res) { | ||
this.transpond = function (req, res, transRules) { | ||
var port = req.headers.host.split(":")[1] || 80; | ||
delete require.cache[path.join(__dirname, "../../config.js")]; | ||
var transRules = { | ||
"7676": { | ||
//目标服务器的ip和端口,域名也可,但注意不要被host了 | ||
targetServer: { | ||
"host": "10.46.133.242",//gcrm | ||
"port": "8101" | ||
// "host": "172.21.206.166",//gcrm | ||
// "port": "8080" | ||
// "host": "172.21.206.84",//gcrm | ||
// "port": "8081" | ||
}, | ||
//特殊请求转发,可选配置,内部的host、port和attachHeaders为可选参数 | ||
regExpPath: { | ||
"gcrm/" : { | ||
path : "gcrm/" | ||
} | ||
// , | ||
// "vendor/": { | ||
// "host": "127.0.0.1", | ||
// "port": "7777", | ||
// "path": "vendor/" | ||
// } | ||
} | ||
}, | ||
"ajaxOnly": false | ||
}; | ||
if (transRules.ajaxOnly && !req.headers.accept.match(/application\/json, text\/javascript/)) { | ||
@@ -36,0 +11,0 @@ res.writeHead("404"); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15801