Class Endpoint<TRequest, TResponse, TMapper>
use this base class for defining endpoints that use both request and response dtos as well as require mapping to and from a domain entity using a seperate entity mapper.
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public abstract class Endpoint<TRequest, TResponse, TMapper> : Endpoint<TRequest, TResponse>, IEndpoint, IEventBus, IServiceResolverBase, IHasMapper<TMapper>, IHasMapper where TRequest : notnull where TResponse : notnull where TMapper : IMapper
Type Parameters
Name | Description |
---|---|
TRequest | the type of the request dto |
TResponse | the type of the response dto |
TMapper | the type of the entity mapper |
Properties
Map
the entity mapper for the endpoint
HINT: entity mappers are singletons for performance reasons. do not maintain state in the mappers.
Declaration
public TMapper Map { get; set; }
Property Value
Type | Description |
---|---|
TMapper |
Methods
SendMappedAsync<TEntity>(TEntity, int, CancellationToken)
send a response by mapping the supplied entity using this endpoint's mapper's ASYNC mapping method.
Declaration
protected Task SendMappedAsync<TEntity>(TEntity entity, int statusCode = 200, CancellationToken ct = default)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | the entity instance to map to the response |
int | statusCode | the status code to send |
CancellationToken | ct | optional cancellation token |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
TEntity | the type of the entity supplied |
SendMapped<TEntity>(TEntity, int, CancellationToken)
send a response by mapping the supplied entity using this endpoint's mapper's SYNC mapping method.
Declaration
protected Task SendMapped<TEntity>(TEntity entity, int statusCode = 200, CancellationToken ct = default)
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | the entity instance to map to the response |
int | statusCode | the status code to send |
CancellationToken | ct | optional cancellation token |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
TEntity | the type of the entity supplied |