-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create sample using IProblemDetailsWriter #34
Comments
@brunolins16 should we have a See |
@brunolins16 I'm closing this unless you think we need a cc @Elfocrash in case you're interested in writing a sample |
@Rick-Anderson sorry I missed the first comment, few days ago, we already added a good doc for the ProblemDetails service and maybe just mention is good enough, is important to also mention "Register any IProblemDetailsWriter implementations before the call to the AddProblemDetails". |
What that means? |
The code doesn't work. |
OH! My bad, I just checked and it really doesn't work. I tried to simplify but I missed / changed too much 😢 |
This is how the blog post code should be public class SampleProblemDetailsWriter : IProblemDetailsWriter
{
public bool CanWrite(ProblemDetailsContext context)
=> context.HttpContext.Response.StatusCode == 400;
public ValueTask WriteAsync(ProblemDetailsContext context)
{
//Additional customizations
// Write to the response
return new ValueTask(context.HttpContext.Response.WriteAsJsonAsync(context.ProblemDetails));
}
} |
IProblemDetailsWriter
from problem details responseIn https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/fundamentals/middleware/problem-details-service or write a new sample in https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/fundamentals/middleware
cc @sammychinedu2ky
The text was updated successfully, but these errors were encountered: