Carter icon indicating copy to clipboard operation
Carter copied to clipboard

can't find much on IResponseNegotiator docs or samples

Open drdamour opened this issue 3 years ago • 1 comments

i'm intrigued by this idea as i think it'll help me return different representations for accept: application/hal+json vs application/vnd.mason+json for example, but i couldn't find much on it. hoping there's some stuff out there i'm missing

drdamour avatar Dec 26 '21 18:12 drdamour

You are correct in your assumption and correct in a lack of samples which will need fixing in the future. For now I can point you to the tests

https://github.com/CarterCommunity/Carter/blob/main/test/Carter.Tests/ContentNegotiation/ResponseNegotiatorTests.cs

On Sun, 26 Dec 2021 at 18:54, drdamour @.***> wrote:

i'm intrigued by this idea as i think it'll help me return different representations for accept: application/hal+json vs application/vnd.mason+json for example, but i couldn't find much on it. hoping there's some stuff out there i'm missing

— Reply to this email directly, view it on GitHub https://github.com/CarterCommunity/Carter/issues/290, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZVJRKB3LA5ALBWMNNJGDUS5QERANCNFSM5KZFWUQQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jchannon avatar Dec 26 '21 19:12 jchannon

@jchannon did samples get added somewhere?

drdamour avatar Sep 21 '22 15:09 drdamour

No, I think the tests are pretty clear

jchannon avatar Sep 21 '22 15:09 jchannon

hm, not to be flippant, but based on what? have people successfully created em from the tests?

drdamour avatar Sep 21 '22 16:09 drdamour

There's some usage in the tests here: https://github.com/CarterCommunity/Carter/blob/main/test/Carter.Tests/ContentNegotiation/ResponseNegotiatorTests.cs#L113-L160

Without a more specific request for what you'd like to know about it this would be impossible to give you something you're satisfied with.

JoeStead avatar Sep 21 '22 16:09 JoeStead

Well you just create a class and implement the interface that has 2 methods. Here's an example:

https://github.com/CarterCommunity/Carter/blob/main/test/Carter.Tests/ContentNegotiation/ResponseNegotiatorTests.cs#L113

It says this negotiator will be used when the accept header is foo/bar and then in the Handle method it's up to you how you write the response.

jchannon avatar Sep 21 '22 16:09 jchannon