17 lines
322 B
TypeScript
17 lines
322 B
TypeScript
import type { MiddlewareHandler } from 'hono';
|
|
|
|
type Env = {
|
|
Variables: {
|
|
requestId: string;
|
|
};
|
|
};
|
|
|
|
export const requestIdMiddleware: MiddlewareHandler<Env> = async (c, next) => {
|
|
const requestId = crypto.randomUUID();
|
|
|
|
c.set('requestId', requestId);
|
|
c.header('X-Request-Id', requestId);
|
|
|
|
await next();
|
|
};
|