Skip to content

Use the 'request' event instead of calling the first event handler di…#1107

Open
pixcai wants to merge 3 commits intosenchalabs:masterfrom
pixcai:master
Open

Use the 'request' event instead of calling the first event handler di…#1107
pixcai wants to merge 3 commits intosenchalabs:masterfrom
pixcai:master

Conversation

@pixcai
Copy link
Copy Markdown

@pixcai pixcai commented Jun 15, 2018

const http = require('http')
const connect = require('connect')

const app = connect()
const server = http.createServer()

server.addListener('request', (req, res) => console.log('hello'))
server.addListener('request', (req, res) => console.log('world'))

app.use('/hello', server)
app.use('/hello', (req, res) => res.end('nodejs'))

app.listen(3000)

If only use the first handler, "hello" can be output to the console, however "world" and res.end('nodejs') will not be invoked, while emit('request') can. Maybe we should do this?

@dougwilson
Copy link
Copy Markdown
Contributor

It's certainly possible to add. Can you add tests to our test suite for this, please?

@pixcai
Copy link
Copy Markdown
Author

pixcai commented Jun 15, 2018

Update and add test

Copy link
Copy Markdown

@WestPop1 WestPop1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gracias

@rmcsharry
Copy link
Copy Markdown

Shouldn't the readme also be updated, since this is quite a fundamental change to how Connect works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants