@@ -39,7 +39,6 @@ export default class PromiseRouter {
39
39
// location: optional. a location header
40
40
constructor ( routes = [ ] , appId ) {
41
41
this . routes = routes ;
42
- this . middlewares = [ ] ;
43
42
this . appId = appId ;
44
43
this . mountRoutes ( ) ;
45
44
}
@@ -55,10 +54,6 @@ export default class PromiseRouter {
55
54
}
56
55
} ;
57
56
58
- use ( middleware ) {
59
- this . middlewares . push ( middleware ) ;
60
- }
61
-
62
57
route ( method , path , ...handlers ) {
63
58
switch ( method ) {
64
59
case 'POST' :
@@ -117,8 +112,7 @@ export default class PromiseRouter {
117
112
this . routes . forEach ( ( route ) => {
118
113
let method = route . method . toLowerCase ( ) ;
119
114
let handler = makeExpressHandler ( this . appId , route . handler ) ;
120
- let args = [ ] . concat ( route . path , this . middlewares , handler ) ;
121
- expressApp [ method ] . apply ( expressApp , args ) ;
115
+ expressApp [ method ] . call ( expressApp , route . path , handler ) ;
122
116
} ) ;
123
117
return expressApp ;
124
118
} ;
@@ -175,7 +169,7 @@ function makeExpressHandler(appId, promiseHandler) {
175
169
176
170
if ( result . text ) {
177
171
res . send ( result . text ) ;
178
- return next ( ) ;
172
+ return ;
179
173
}
180
174
181
175
if ( result . location ) {
@@ -184,7 +178,7 @@ function makeExpressHandler(appId, promiseHandler) {
184
178
// as it double encodes %encoded chars in URL
185
179
if ( ! result . response ) {
186
180
res . send ( 'Found. Redirecting to ' + result . location ) ;
187
- return next ( ) ;
181
+ return ;
188
182
}
189
183
}
190
184
if ( result . headers ) {
@@ -193,7 +187,6 @@ function makeExpressHandler(appId, promiseHandler) {
193
187
} )
194
188
}
195
189
res . json ( result . response ) ;
196
- next ( ) ;
197
190
} , ( e ) => {
198
191
log . error ( `Error generating response. ${ inspect ( e ) } ` , { error : e } ) ;
199
192
next ( e ) ;
0 commit comments