可以在Javascript中使用context
来访问代理服务的上下文信息。
示例1:打印Server信息:
console.log(context.server);
示例2:根据Backend ID来查找一个后端服务器信息(从v0.1.9开始):
var backend = context.server.findBackend("0biKxy56Y4sUoo9Z");
console.log(backend.address);
http.Server = function (options) {
this.isOn = true;
this.id = "";
this.filename = "";
this.name = [];
this.description = "";
this.listen = [];
this.backends = [];
this.locations = [];
this.http = true;
this.ssl = {};
// 查找后端服务器
this.findBackend = function (backendId) {};
// 查找路径规则
this.findLocation = function (locationId) {};
};
http.Backend = function (options) {
this.isOn = true;
this.id = "";
this.address = "";
this.weight = 0;
this.isDown = false;
this.isBackup = false;
this.name = [];
this.code = "";
};
http.Location = function (options) {
this.isOn = true;
this.pattern = "";
this.cachePolicy = "";
this.fastcgi = [];
this.id = "";
this.index = [];
this.root = "";
this.rewrite = [];
this.websocket = {};
this.backends = [];
this.findBackend = function (backendId) {};
}
http.Fastcgi = function (options) {
this.id = "";
this.isOn = true;
this.pass = "";
};
http.Rewrite = function (options) {
this.id = "";
this.isOn = true;
this.pattern = "";
this.replace = "";
};