@@ -17,8 +17,7 @@ var http = require('http'),
17
17
util = require ( 'util' ) ,
18
18
URL = require ( 'url' ) ,
19
19
querystring = require ( 'querystring' ) ,
20
- store = require ( './store.js' ) ,
21
- trie = require ( './trie.js' ) ;
20
+ store = require ( './store.js' ) ;
22
21
23
22
function bound ( that , method ) {
24
23
// bind a method, to ensure `this=that` when it is called
@@ -103,7 +102,6 @@ function ConfigurableProxy (options) {
103
102
this . options = options || { } ;
104
103
105
104
this . _routes = store . MemoryStore ( ) ;
106
- this . trie = new trie . URLTrie ( ) ;
107
105
this . auth_token = this . options . auth_token ;
108
106
this . includePrefix = options . includePrefix === undefined ? true : options . includePrefix ;
109
107
this . host_routing = this . options . host_routing ;
@@ -189,20 +187,18 @@ util.inherits(ConfigurableProxy, EventEmitter);
189
187
190
188
ConfigurableProxy . prototype . add_route = function ( path , data ) {
191
189
// add a route to the routing table
192
- path = trie . trim_prefix ( path ) ;
190
+ path = this . _routes . cleanPath ( path ) ;
193
191
if ( this . host_routing && path !== '/' ) {
194
192
data . host = path . split ( '/' ) [ 1 ] ;
195
193
}
196
194
this . _routes . add ( path , data ) ;
197
- this . trie . add ( path , data ) ;
198
195
this . update_last_activity ( path ) ;
199
196
} ;
200
197
201
198
ConfigurableProxy . prototype . remove_route = function ( path ) {
202
199
// remove a route from the routing table
203
200
if ( this . _routes . hasRoute ( path ) ) {
204
201
this . _routes . remove ( path ) ;
205
- this . trie . remove ( path ) ;
206
202
}
207
203
} ;
208
204
@@ -274,7 +270,7 @@ ConfigurableProxy.prototype.target_for_req = function (req) {
274
270
var timer = this . statsd . createTimer ( 'find_target_for_req' ) ;
275
271
// return proxy target for a given url path
276
272
var base_path = ( this . host_routing ) ? '/' + parse_host ( req ) : '' ;
277
- var route = this . trie . get ( trie . string_to_path ( base_path + decodeURIComponent ( req . url ) ) ) ;
273
+ var route = this . _routes . getTarget ( base_path + decodeURIComponent ( req . url ) ) ;
278
274
timer . stop ( ) ;
279
275
if ( route ) {
280
276
return {
0 commit comments