From 4a0c55cc96803f116e6307d78c3c1887ef6765f3 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Mon, 2 Sep 2013 19:13:47 -0700 Subject: [PATCH] docs --- docs/guide.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/guide.md b/docs/guide.md index 9c08c45..337746b 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -39,6 +39,20 @@ app.use(function(next){ ![koa middleware](https://i.cloudup.com/N7L5UakJo0.gif) + 1. Create a date to track duration + 2. Yield control to the next middleware + 3. Create another date to track response time + 4. Yield control to the next middleware + 5. Yield immediately since `contentLength` only works with responses + 6. Yield upstream to Koa's noop middleware + 7. Ignore setting the body unless the path is "/" + 8. Set the response to "Hello World" + 9. Ignore setting Content-Length when no body is present + 10. Set the field + 11. Output log line + 12. Set `X-Response-Time` header field before response + 13. Hand off to Koa to handle the response + Next we'll look at the best practices for creating Koa middleware. ## Middleware Best Practices