@@ -36,6 +36,24 @@ http.Server = function (options) {
36
36
}
37
37
}
38
38
}
39
+
40
+ this . findBackend = function ( backendId ) {
41
+ for ( var i = 0 ; i < this . backends . length ; i ++ ) {
42
+ if ( this . backends [ i ] . id == backendId ) {
43
+ return this . backends [ i ] ;
44
+ }
45
+ }
46
+
47
+ // location
48
+ for ( var i = 0 ; i < this . locations . length ; i ++ ) {
49
+ var backend = this . locations [ i ] . findBackend ( backendId ) ;
50
+ if ( backend != null ) {
51
+ return backend ;
52
+ }
53
+ }
54
+
55
+ return null ;
56
+ } ;
39
57
} ;
40
58
41
59
http . Backend = function ( options ) {
@@ -46,6 +64,7 @@ http.Backend = function (options) {
46
64
this . isDown = false ;
47
65
this . isBackup = false ;
48
66
this . name = [ ] ;
67
+ this . code = "" ;
49
68
50
69
if ( options != null && typeof ( options ) == "object" ) {
51
70
for ( var key in options ) {
@@ -67,6 +86,7 @@ http.Location = function (options) {
67
86
this . root = "" ;
68
87
this . rewrite = [ ] ;
69
88
this . websocket = { } ;
89
+ this . backends = [ ] ;
70
90
71
91
if ( options != null && typeof ( options ) == "object" ) {
72
92
for ( var key in options ) {
@@ -84,11 +104,30 @@ http.Location = function (options) {
84
104
var rewrite = new http . Rewrite ( value [ i ] ) ;
85
105
this . rewrite . push ( rewrite ) ;
86
106
}
87
- } else if ( typeof ( key ) == "string" && typeof ( this [ key ] ) == typeof ( value ) ) {
107
+ }
108
+ // backends
109
+ else if ( key == "backends" ) {
110
+ for ( var i = 0 ; i < value . length ; i ++ ) {
111
+ var backend = new http . Backend ( value [ i ] ) ;
112
+ this . backends . push ( backend ) ;
113
+ }
114
+ }
115
+ // others
116
+ else if ( typeof ( key ) == "string" && typeof ( this [ key ] ) == typeof ( value ) ) {
88
117
this [ key ] = value ;
89
118
}
90
119
}
91
120
}
121
+
122
+ this . findBackend = function ( backendId ) {
123
+ for ( var i = 0 ; i < this . backends . length ; i ++ ) {
124
+ if ( this . backends [ i ] . id == backendId ) {
125
+ return this . backends [ i ] ;
126
+ }
127
+ }
128
+
129
+ return null ;
130
+ } ;
92
131
} ;
93
132
94
133
http . Fastcgi = function ( options ) {
0 commit comments