Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Make res middleware reflect opposite direction #1

merged 1 commit into from

2 participants


prev is the natural opposite of next.

@timshadel timshadel Make res middleware reflect opposite direction
`prev` is the natural opposite of `next`.

If you look at the code underneath, it's not going to the previous middleware though. It still gets executed in the same order as your request stack. I don't know if prev indicates that happening


That's bad, then. All middleware needs to be reverse executed on response. Even standard connect stuff you override end, then execute this layer, then call end (executing previous layers).


Make sense. I'll fix it then

@camshaft camshaft merged commit 1f6a5c5 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 1, 2013
  1. @timshadel

    Make res middleware reflect opposite direction

    timshadel authored
    `prev` is the natural opposite of `next`.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 3 deletions.
  1. +2 −3 test/node/middleware.js
5 test/node/middleware.js
@@ -1,4 +1,3 @@
var request = require('../..')
, express = require('express')
, should = require("should")
@@ -44,11 +43,11 @@ describe('req.use(Function)', function(){
.use(function(req, next) {
req.setHeader("x-test","This is a test");
- next(null, function(res, resNext) {
+ next(null, function(res, prev) {
res.on('data', function(data) {
res.headers['x-test-inject'] = "This is a header";
- resNext();
+ prev();
.end(function(err, res){
Something went wrong with that request. Please try again.