Created
April 7, 2015 23:05
-
-
Save PandaWhisperer/cf0656c7c2b93702ccea 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
koa = require("koa") | |
app = koa() | |
# x-response-time | |
app.use (next) -> | |
start = new Date | |
yield next | |
ms = new Date - start | |
@set 'X-Response-Time', ms + 'ms' | |
# logger | |
app.use (next) -> | |
start = new Date | |
yield next | |
ms = new Date - start | |
console.log '%s %s - %s', this.method, this.url, ms | |
# response | |
app.use (next) -> | |
this.body = "Hello World" | |
yield next | |
app.listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment