UNPKG

egg-apigw-tracer

Version:

适配 API 网关的 HTTP 请求示踪器,用于 Egg.js 框架

12 lines (10 loc) 270 B
'use strict' module.exports = (options, app) => { return async function tracer(ctx, next) { const { mode, idHeader } = options if (!ctx.response.get(idHeader) && mode !== 'apigw') { ctx.set(idHeader, ctx.traceId) } await next() } }