@@ -39,7 +39,6 @@ export default class PromiseRouter {
3939 // location: optional. a location header
4040 constructor ( routes = [ ] , appId ) {
4141 this . routes = routes ;
42- this . middlewares = [ ] ;
4342 this . appId = appId ;
4443 this . mountRoutes ( ) ;
4544 }
@@ -55,10 +54,6 @@ export default class PromiseRouter {
5554 }
5655 } ;
5756
58- use ( middleware ) {
59- this . middlewares . push ( middleware ) ;
60- }
61-
6257 route ( method , path , ...handlers ) {
6358 switch ( method ) {
6459 case 'POST' :
@@ -117,8 +112,7 @@ export default class PromiseRouter {
117112 this . routes . forEach ( ( route ) => {
118113 let method = route . method . toLowerCase ( ) ;
119114 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 ) ;
122116 } ) ;
123117 return expressApp ;
124118 } ;
@@ -175,7 +169,7 @@ function makeExpressHandler(appId, promiseHandler) {
175169
176170 if ( result . text ) {
177171 res . send ( result . text ) ;
178- return next ( ) ;
172+ return ;
179173 }
180174
181175 if ( result . location ) {
@@ -184,7 +178,7 @@ function makeExpressHandler(appId, promiseHandler) {
184178 // as it double encodes %encoded chars in URL
185179 if ( ! result . response ) {
186180 res . send ( 'Found. Redirecting to ' + result . location ) ;
187- return next ( ) ;
181+ return ;
188182 }
189183 }
190184 if ( result . headers ) {
@@ -193,7 +187,6 @@ function makeExpressHandler(appId, promiseHandler) {
193187 } )
194188 }
195189 res . json ( result . response ) ;
196- next ( ) ;
197190 } , ( e ) => {
198191 log . error ( `Error generating response. ${ inspect ( e ) } ` , { error : e } ) ;
199192 next ( e ) ;
0 commit comments