-
-
Save 404pnf/321be31fcddb89d97979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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