Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.

Output Formatter
Since I’m handling Text, I’m going to be deriving from the TextOutputFormatter. This requires you to implement two methods:bool CanWriteType(Type type)
This method determines if your output formatter can handle the type returned from your controller action.
Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
Handle how yo want to transform the object returned from your controller action.
Lastly, you also need to define which media types your output formatter will handle. In other words, when the client sends an Accept: header, which values apply to your output formatter.
In my case, Siren uses application/vnd.siren+json
MVC Options
Finally, in our startup, we need to add our new Output Formatter in the AddMVC extension method.Results
Here are two different outputs. The first is with anAccept: application/json
and the second is requestion Siren with Accept: application/vnd.siren+json

