Skip to content

Instantly share code, notes, and snippets.

@Hoverbear
Created June 19, 2013 03:14
Show Gist options
  • Save Hoverbear/5811440 to your computer and use it in GitHub Desktop.
Save Hoverbear/5811440 to your computer and use it in GitHub Desktop.
Express.js app.use() middleware example.
###
Browse to http://localhost:8080 to see the following output:
# Hello
###
# Ignore
app = require('express')()
# Important stuff!
app.use (req, res)->
console.log "Hello"
app.use (req, res)->
console.log "World"
# Ignore
app.listen 8080
###
Browse to http://localhost:8080 to see the following output:
# Hello World
###
# Ignore
app = require('express')()
# Important stuff!
app.use (req, res, next)->
console.log "Hello"
next()
app.use (req, res, next)->
console.log "World"
next()
# Ignore
app.listen 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment