docs
This commit is contained in:
parent
33221d6574
commit
b132484dcf
1 changed files with 13 additions and 13 deletions
|
@ -39,19 +39,19 @@ 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
|
||||
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
|
||||
|
||||
Note that the final middleware (step __6__) yields to what looks to be nothing - it's actually
|
||||
yielding to a no-op generator within Koa. This is so that every middleware can conform with the
|
||||
|
|
Loading…
Reference in a new issue