@@ -117,23 +117,33 @@ ProxyServer.prototype.listen = function(port) {
117
117
return this ;
118
118
} ;
119
119
120
- ProxyServer . prototype . before = function ( passName , callback ) {
121
- var i = false ;
122
- this . passes . forEach ( function ( v , idx ) {
120
+ ProxyServer . prototype . before = function ( type , passName , callback ) {
121
+ if ( type !== 'ws' || type !== 'web' ) {
122
+ throw new Error ( 'type must be `web` or `ws`' ) ;
123
+ }
124
+ var passes = ( type === 'ws' ) ? this . wsPasses : this . webPasses ,
125
+ i = false ;
126
+
127
+ passes . forEach ( function ( v , idx ) {
123
128
if ( v . name === passName ) i = idx ;
124
129
} )
125
130
126
131
if ( ! i ) throw new Error ( 'No such pass' ) ;
127
132
128
- this . passes . splice ( i , 0 , callback ) ;
133
+ passes . splice ( i , 0 , callback ) ;
129
134
} ;
130
- ProxyServer . prototype . after = function ( passName , callback ) {
131
- var i = false ;
132
- this . passes . forEach ( function ( v , idx ) {
135
+ ProxyServer . prototype . after = function ( type , passName , callback ) {
136
+ if ( type !== 'ws' || type !== 'web' ) {
137
+ throw new Error ( 'type must be `web` or `ws`' ) ;
138
+ }
139
+ var passes = ( type === 'ws' ) ? this . wsPasses : this . webPasses ,
140
+ i = false ;
141
+
142
+ passes . forEach ( function ( v , idx ) {
133
143
if ( v . name === passName ) i = idx ;
134
144
} )
135
145
136
146
if ( ! i ) throw new Error ( 'No such pass' ) ;
137
147
138
- this . passes . splice ( i ++ , 0 , callback ) ;
148
+ passes . splice ( i ++ , 0 , callback ) ;
139
149
} ;
0 commit comments