From 33846d1b9578fd20f2fd5d42835b2a4e64513440 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 31 Dec 2013 10:31:49 -0800 Subject: [PATCH] remove old simple.js example --- examples/simple.js | 48 ---------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 examples/simple.js diff --git a/examples/simple.js b/examples/simple.js deleted file mode 100644 index 56221c5..0000000 --- a/examples/simple.js +++ /dev/null @@ -1,48 +0,0 @@ - -var koa = require('..'); -var app = koa(); - -// x-response-time - -app.use(function *responseTime(next){ - var start = new Date; - yield next; - var ms = new Date - start; - this.set('X-Response-Time', ms + 'ms'); -}); - -// logger - -app.use(function *logger(next){ - var start = new Date; - yield next; - var ms = new Date - start; - console.log('%s %s - %s', this.method, this.url, ms); -}); - -// content-length - -app.use(function *contentLength(next){ - yield next; - if (!this.body) return; - this.set('Content-Length', Buffer.byteLength(this.body)); -}); - -// custom 404 handler - -app.use(function *notfound(next){ - yield next; - if (this.body) return; - this.status = 404; - this.body = 'Sorry! No luck'; -}); - -// response - -app.use(function *response(next){ - yield next; - if ('/' != this.url) return; - this.body = 'Hello World'; -}); - -app.listen(3000);