Skip to content

Commit

Permalink
Merge pull request #65 from nigrosimone/method-chaining
Browse files Browse the repository at this point in the history
fix #64
  • Loading branch information
dimdenGD authored Nov 24, 2024
2 parents b575e14 + 3b67ef4 commit 6b449ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ module.exports = class Router extends EventEmitter {
}
}
this.createRoute('USE', path, this, ...callbacks);
return this;
}

route(path) {
Expand Down
24 changes: 24 additions & 0 deletions tests/tests/app/app-use-chaining.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// must support app chaining

const express = require("express");

const app = express();
app.disable('etag');

app.use((req, res, next) => {
res.setHeader('a', '1')
next();
}).use((req, res, next) => {
res.setHeader('b', '1')
next();
})

app.get('/abc', (req, res) => {
res.send('abc');
});

app.listen(13333, async () => {
const output = await fetch('http://localhost:13333/abc');
console.log(output.headers.get('etag'));
process.exit(0);
});

0 comments on commit 6b449ab

Please sign in to comment.