Skip to content

Instantly share code, notes, and snippets.

@404pnf
Forked from geta6/koa.coffee
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 404pnf/321be31fcddb89d97979 to your computer and use it in GitHub Desktop.
Save 404pnf/321be31fcddb89d97979 to your computer and use it in GitHub Desktop.
'use strict'
koa = require 'koa'
app = koa()
note = console.log
time_logger = (next) ->
start = Date.now()
yield next
note "耗时: #{Date.now() - start} 毫秒"
method_logger = (next) ->
note "#{@method}: #{@url}"
yield next
app.use time_logger
app.use method_logger
app.use ->
yield return this.body = 'Hello from coffeescript on koa.'
app.listen 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment