mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 19:50:01 +08:00
27 lines
576 B
TypeScript
27 lines
576 B
TypeScript
import { MiddlewareHandler } from "hono";
|
|
import { getDebugInfo, setDebugInfo } from "@/utils/debug-info";
|
|
|
|
const middleware: MiddlewareHandler = async (ctx, next) => {
|
|
{
|
|
const debug = getDebugInfo();
|
|
debug.request++;
|
|
setDebugInfo(debug);
|
|
}
|
|
|
|
await next();
|
|
|
|
{
|
|
const debug = getDebugInfo();
|
|
if (ctx.res.headers.get('RSSHub-Cache-Status')) {
|
|
debug.hitCache++;
|
|
}
|
|
|
|
if (ctx.res.status === 304) {
|
|
debug.etag++;
|
|
}
|
|
setDebugInfo(debug);
|
|
}
|
|
};
|
|
|
|
export default middleware;
|