Skip to content
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

Open
Rick-Anderson opened this issue Sep 8, 2022 · 7 comments
Open

Create sample using IProblemDetailsWriter #34

Rick-Anderson opened this issue Sep 8, 2022 · 7 comments

Comments

@Rick-Anderson
Copy link
Contributor

Rick-Anderson commented Sep 8, 2022

@Rick-Anderson
Copy link
Contributor Author

Rick-Anderson commented Sep 15, 2022

@brunolins16 should we have a IProblemDetailsWriter sample or should we just say, you can create your own IProblemDetailsWriter implementation for advanced customizations. See the ProblemDetailsService for an example.

See IProblemDetailsWriter from problem details response which has a few problems.

@Rick-Anderson
Copy link
Contributor Author

Rick-Anderson commented Oct 11, 2022

@brunolins16 I'm closing this unless you think we need a IProblemDetailsWriter sample or should we just say, you can create your own IProblemDetailsWriter implementation for advanced customizations. See the ProblemDetailsService for an example.

cc @Elfocrash in case you're interested in writing a sample

@brunolins16
Copy link
Member

@brunolins16 I'm closing this unless you think we need a IProblemDetailsWriter sample or should we just say, you can create your own IProblemDetailsWriter implementation for advanced customizations. See the ProblemDetailsService for an example.

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".

@brunolins16
Copy link
Member

See IProblemDetailsWriter from problem details response which has a few problems.

What that means?

@Rick-Anderson
Copy link
Contributor Author

See IProblemDetailsWriter from problem details response which has a few problems.

The code doesn't work.

@brunolins16
Copy link
Member

See IProblemDetailsWriter from problem details response which has a few problems.

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 😢

@brunolins16
Copy link
Member

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));
    }
}

@Rick-Anderson Rick-Anderson added reQUEST Triggers an issue to be imported into Quest and removed reQUEST Triggers an issue to be imported into Quest labels Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants