Created
May 30, 2016 11:53
-
-
Save ockham/2892ef443766a51ef32c8a7b77a8c2ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 08a78d6db7955cf469063d0bc50a5550fa02b0df | |
Author: Bernhard Reiter <[email protected]> | |
Date: Mon May 30 13:50:35 2016 +0200 | |
Iso-routing: Pass next() to applyMiddlewares() | |
This way, it will be called in the right order even if there is an async invocation in the mw chain. | |
diff --git a/server/isomorphic-routing/index.js b/server/isomorphic-routing/index.js | |
index 3a35066..271c1d2 100644 | |
--- a/server/isomorphic-routing/index.js | |
+++ b/server/isomorphic-routing/index.js | |
@@ -13,16 +13,17 @@ export function serverRouter( expressApp, setUpRoute, section ) { | |
combineMiddlewares( | |
setSectionMiddlewareFactory( section ), | |
...middlewares | |
- ) | |
+ ), | |
+ serverRender | |
); | |
}; | |
} | |
function combineMiddlewares( ...middlewares ) { | |
- return function( req, res ) { | |
+ return function( req, res, next ) { | |
req.context = getEnhancedContext( req ); | |
applyMiddlewares( req.context, ...middlewares, () => { | |
- serverRender( req, res ); | |
+ next(); | |
} ); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Iso-routing: Pass next() to applyMiddlewares()
This way, it will be called in the right order even if there is an async invocation in the mw chain.