|
public ValueTask WriteAsync(ProblemDetailsContext context) |
|
{ |
|
var httpContext = context.HttpContext; |
|
ProblemDetailsDefaults.Apply(context.ProblemDetails, httpContext.Response.StatusCode); |
|
|
|
var traceId = Activity.Current?.Id ?? httpContext.TraceIdentifier; |
|
var traceIdKeyName = _serializerOptions.PropertyNamingPolicy?.ConvertName("traceId") ?? "traceId"; |
|
context.ProblemDetails.Extensions[traceIdKeyName] = traceId; |
|
|
|
_options.CustomizeProblemDetails?.Invoke(context); |
|
|
|
var problemDetailsType = context.ProblemDetails.GetType(); |
|
|
|
return new ValueTask(httpContext.Response.WriteAsJsonAsync( |
|
context.ProblemDetails, |
|
_serializerOptions.GetTypeInfo(problemDetailsType), |
|
contentType: "application/problem+json")); |
|
} |
HttpContext has RequestAborted property (of type CancellationToken). WriteAsJsonAsync accepts an optional cancellation token. Should we be passing the cancellation token in this code path?
aspnetcore/src/Http/Http.Extensions/src/DefaultProblemDetailsWriter.cs
Lines 53 to 70 in 05434a9
HttpContexthasRequestAbortedproperty (of typeCancellationToken).WriteAsJsonAsyncaccepts an optional cancellation token. Should we be passing the cancellation token in this code path?