Mappers¶
Mappers need to be created between the following:
- Request Dto -> Request Domain (Query or Command)
- Response Domain -> Response Dto
- Response Data Domain -> Response Data Dto
These mappers are specified using the fluent API used to create a WebApiEndpoint.
Mappers are registered as singletons in IoC.
Request Dto -> Request Domain (Query or Command)¶
If a WebApiEndpoint has a Request Domain, a mapper needs be created. The Request Domain will either be a Query or a Command.
This mapper needs to implement the 'IWebApiEndpointRequestMapper' interface. This comes in two forms:
- IWebApiEndpointRequestMapper<TDomain>
This is used when there is not a Request Dto. So the Request Domain must be created from data from the HttpContext.
See map-from binding as it should cover a lot of these scenarios for getting data from HttpContext.
- IWebApiEndpointRequestMapper<TDto, TDomain>
This is used when there is a Request Dto. So the Request Domain must be created from data from the Request Domain and optionally from the HttpContext.
See map-from binding as it should cover a lot of these scenarios for getting data from HttpContext.
Response Domain -> Response Dto¶
If a WebApiEndpoint has a response, a mapper needs be created.
This mapper needs to implement the 'IWebApiEndpointResponseMapper<TDomain, TDto>' interface.
Response Data Domain -> Response Data Dto¶
If a WebApiEndpoint has a response that is either of the following two types, then a data mapper needs be created:
This mapper needs to implement the 'IWebApiEndpointResponseDataMapper<TData, TDataDto>' interface.