var metadata = new Metadata
{
{ "x-trace-id", $"123456789" }
};
var channel = GrpcChannel.ForAddress($"http://172.17.12.175:20026");
// 开发环境请求地址var client = new UserAudioServiceClient(channel);
var res = client.AddOrUpdateUserAudio(new Beta.VideoSettings.GrpcServer.AddOrUpdateReuest()
{
AudioSynthesisId = "1",
BetaUnionId = 72057594038339269,
BusinessId = "180941",
ModuleId = 57006
}, metadata); // 添加请求头
public override async Task<UserAudioReply> GetUserAudio(UserAudioRequest request, ServerCallContext context)
{
var replay = new UserAudioReply()
{
Status = StatusEnum.Success
};
try
{
_logger.LogError("dddd");
var userAudio = await _userAudioQuery.GetUserAudioAsync(
request.BetaUnionId,
request.ModuleId,
request.BusinessId);
replay.Data = _mapper.Map<UserAudioResult>(userAudio);
}
catch (System.Exception e)
{
replay.Status = StatusEnum.Fail;
replay.Msg = "程序出错";
_logger.LogError("早报内容转音频出错 - GetUserAudio", e);
}
return replay;
}
ServerCallContext context中就可以看到添加的Header头
可在拦截器中添加请求头,interceptor