test: middleware/debug

This commit is contained in:
DIYgod
2019-01-29 18:22:59 +08:00
parent e90f940ada
commit 42ed46532b
2 changed files with 55 additions and 8 deletions

View File

@@ -9,16 +9,11 @@ module.exports = async (ctx, next) => {
ctx.debug.ips[ip] = 0;
}
ctx.debug.ips[ip]++;
if (ctx.request.path !== '/') {
ctx.debug.request++;
}
ctx.debug.request++;
await next();
if (ctx.request.path !== '/') {
if (ctx.response.get('X-Koa-Redis-Cache') || ctx.response.get('X-Koa-Memory-Cache')) {
ctx.debug.hitCache++;
}
if (ctx.response.get('X-Koa-Redis-Cache') || ctx.response.get('X-Koa-Memory-Cache')) {
ctx.debug.hitCache++;
}
};