Skip to content

Commit

Permalink
Ensure the middleware will be called at most once for one request.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsm committed Dec 1, 2015
1 parent 4262cca commit c39204f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/web/middleware/express-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ module.exports = function(app) {
app.set('micromono layout name', layoutName)

return function renderLayout(req, res, next) {
if (req.__micromono_layout_attached__) {
next()
return
}
req.__micromono_layout_attached__ = true

var _end = res.end
var _write = res.write
var _writeHead = res.writeHead
Expand Down

0 comments on commit c39204f

Please sign in to comment.