How I am using IActionConstraintFactory to handle content negotiation
Resource representation based on accept type
I am assuming in this article that you already know what Rest and RestApi are, or if you are like me then you practice them, but it’s not easy to find the correct terminology to explain them.
I have to be frank, while I worked with API's pretty much in the last couple of years, and while I have read multiple articles (and watched multiple tutorials) regarding True Rest and HateOS, I haven’t actually worked with True Rest in practice…until now.
Why content negotiation? Because Rest resources can have multiple presentations depending on who is requesting that information. One can be the HR department, another one can be the Accounting department, and both would like different types of information regarding the same resource.
But, I am not going to write about content negotiation, but instead about how I am achieving that with IActionConstraintFactory
, in order to have the same endpoint for the clients.
You can find a link to the demo using the following link: https://github.com/ramihamati/webapidemos/tree/main/WebApi.DemoActionConstraintFactory