Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make res middleware reflect opposite direction #1

Merged
merged 1 commit into from

2 participants

@timshadel
Collaborator

prev is the natural opposite of next.

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

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

@timshadel
Collaborator

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).

@camshaft
Owner

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
View
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(){
.get('http://localhost:3045/')
.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.