更新web服务器自定义token解析回调
This commit is contained in:
@@ -9,7 +9,10 @@ class TraceDio {
|
||||
final Uuid uuid = Uuid();
|
||||
|
||||
static late TraceDio _traceDio;
|
||||
//token
|
||||
String? token;
|
||||
//自定义查询条件
|
||||
Map<String, String> queryParameters = {};
|
||||
|
||||
TraceDio(Logger? logger)
|
||||
: _dio = Dio(),
|
||||
@@ -25,6 +28,8 @@ class TraceDio {
|
||||
// 设置拦截器,自动添加 traceId 和 spanId,并记录日志
|
||||
_dio.interceptors.add(InterceptorsWrapper(
|
||||
onRequest: (options, handler) {
|
||||
//动态添加请求参数
|
||||
options.queryParameters.addAll(queryParameters);
|
||||
// 获取请求中的 traceId(如果没有则生成)
|
||||
String? traceId = options.headers['X-Trace-ID'];
|
||||
String? spanId = options.headers['X-Span-ID'];
|
||||
|
||||
Reference in New Issue
Block a user