Functions, Utilities and Helpers that enable the use of Hypermedia as the Engine of Application State (HATEOAS).
-
Asp.Net Standard/Core Dependency Injection
- Use the provided
services.AddHypermedia(string vendorName) method
- The vendorName string is used to build your HATEOAS accepted media type values (e.g. application/vnd.[VENDORNAME].hateoas+json)
- Use the provided
-
Other containers
- Register your supported media types into the relevant output formatters
- Register the Web Api controllers, adding the
ValidateMediaTypeAttribute
as a filter; alternatively add [ServiceFilter(typeof(ValidateMediaTypeAttribute))] to your controllers. - Register your output formatters into the container
- Create a mapping class inheriting from
ControllerMap<TController, TReadModel>
and in the controller callCreateLinkDefinition
for all the different HATEOAS links yourTReadModel
will need - Make your
TController
inherit fromHypermediaControllerBase
and return as normal.Ok
andCreated
IActionResults will automatically detect the defined links and add them to your response. - NB: If the accept header does not include a valid HATEOAS media type, then the response will not be amended to include the links