mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 18:48:12 +08:00
27 lines
663 B
JavaScript
27 lines
663 B
JavaScript
module.exports = async (ctx, next) => {
|
|
if (!ctx.debug.paths[ctx.request.path]) {
|
|
ctx.debug.paths[ctx.request.path] = 0;
|
|
}
|
|
ctx.debug.paths[ctx.request.path]++;
|
|
|
|
const ip = ctx.ips[0] || ctx.ip;
|
|
if (!ctx.debug.ips[ip]) {
|
|
ctx.debug.ips[ip] = 0;
|
|
}
|
|
ctx.debug.ips[ip]++;
|
|
ctx.debug.request++;
|
|
|
|
await next();
|
|
|
|
if (!ctx.debug.routes[ctx._matchedRoute]) {
|
|
ctx.debug.routes[ctx._matchedRoute] = 0;
|
|
}
|
|
ctx.debug.routes[ctx._matchedRoute]++;
|
|
|
|
if (ctx.response.get('X-Koa-Redis-Cache') || ctx.response.get('X-Koa-Memory-Cache')) {
|
|
ctx.debug.hitCache++;
|
|
}
|
|
|
|
ctx.state.debuged = true;
|
|
};
|