fix(core): healthz bypass cache (#16455)

This commit is contained in:
Tony
2024-08-16 00:50:31 +08:00
committed by GitHub
parent 8a3c8e1603
commit adce4057dc
3 changed files with 18 additions and 1 deletions
+8
View File
@@ -29,4 +29,12 @@ describe('registry', () => {
const response = await app.request('/favicon.ico');
expect(response.status).toBe(200);
});
// healthz
it('/healthz', async () => {
const response = await app.request('/healthz');
expect(response.status).toBe(200);
expect(response.headers.get('cache-control')).toBe('no-cache');
expect(await response.text()).toBe('ok');
});
});
+2 -1
View File
@@ -7,6 +7,7 @@ import { serveStatic } from '@hono/node-server/serve-static';
import { config } from '@/config';
import index from '@/routes/index';
import healthz from '@/routes/healthz';
import robotstxt from '@/routes/robots.txt';
import metrics from '@/routes/metrics';
@@ -100,7 +101,7 @@ for (const namespace in namespaces) {
}
app.get('/', index);
app.get('/healthz', (ctx) => ctx.text('ok'));
app.get('/healthz', healthz);
app.get('/robots.txt', robotstxt);
if (config.debugInfo) {
// Only enable tracing in debug mode
+8
View File
@@ -0,0 +1,8 @@
import type { Handler } from 'hono';
const handler: Handler = (ctx) => {
ctx.header('Cache-Control', 'no-cache');
return ctx.text('ok');
};
export default handler;