docs: A middleware is always responsible for calling downstream (#978)

Irrespective of whether it is called by an upstream middleware or not.
This commit is contained in:
designgrill 2017-06-13 00:08:25 +05:30 committed by jongleberry
parent 0a7856ca15
commit beec26ebf8

View file

@ -6,7 +6,7 @@
## Writing Middleware ## Writing Middleware
Koa middleware are simple functions which return a `MiddlewareFunction` with signature (ctx, next). When Koa middleware are simple functions which return a `MiddlewareFunction` with signature (ctx, next). When
the middleware is run by an "upstream" middleware, it must manually invoke `next()` to run the "downstream" middleware. the middleware is run, it must manually invoke `next()` to run the "downstream" middleware.
For example if you wanted to track how long it takes for a request to propagate through Koa by adding an For example if you wanted to track how long it takes for a request to propagate through Koa by adding an
`X-Response-Time` header field the middleware would look like the following: `X-Response-Time` header field the middleware would look like the following: