Advertisement
Guest User

Untitled

a guest
May 30th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. commit 08a78d6db7955cf469063d0bc50a5550fa02b0df
  2. Author: Bernhard Reiter <ockham@raz.or.at>
  3. Date: Mon May 30 13:50:35 2016 +0200
  4.  
  5. Iso-routing: Pass next() to applyMiddlewares()
  6.  
  7. This way, it will be called in the right order even if there is an async invocation in the mw chain.
  8.  
  9. diff --git a/server/isomorphic-routing/index.js b/server/isomorphic-routing/index.js
  10. index 3a35066..271c1d2 100644
  11. --- a/server/isomorphic-routing/index.js
  12. +++ b/server/isomorphic-routing/index.js
  13. @@ -13,16 +13,17 @@ export function serverRouter( expressApp, setUpRoute, section ) {
  14. combineMiddlewares(
  15. setSectionMiddlewareFactory( section ),
  16. ...middlewares
  17. - )
  18. + ),
  19. + serverRender
  20. );
  21. };
  22. }
  23.  
  24. function combineMiddlewares( ...middlewares ) {
  25. - return function( req, res ) {
  26. + return function( req, res, next ) {
  27. req.context = getEnhancedContext( req );
  28. applyMiddlewares( req.context, ...middlewares, () => {
  29. - serverRender( req, res );
  30. + next();
  31. } );
  32. };
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement