app: debug: add hot routes

This commit is contained in:
DIYgod
2018-05-17 15:01:45 +08:00
parent d24cdb9a21
commit 3d57e5ca75
4 changed files with 32 additions and 5 deletions

View File

@@ -1,8 +1,16 @@
module.exports = async (ctx, next) => {
await next();
if (!ctx.debug.routes[ctx.request.path]) {
ctx.debug.routes[ctx.request.path] = 0;
}
ctx.debug.routes[ctx.request.path]++;
if (ctx.request.path !== '/') {
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++;
}