Class RequestHandlerBase<TRequest, TResponse>
Base class for CommandHandlerBase<TCommand, TResponse> and QueryHandlerBase<TQuery, TResponse>.
public abstract class RequestHandlerBase<TRequest, TResponse> : HandlerBase<TRequest, TResponse> where TRequest : _IRequest<TRequest, TResponse> where TResponse : class
Type Parameters
TRequestThe type of the request being handled.
TResponseThe type of the response produced by the handler.
- Inheritance
-
HandlerBase<TRequest, TResponse>RequestHandlerBase<TRequest, TResponse>
- Derived
-
CommandHandlerBase<TCommand, TResponse>QueryHandlerBase<TQuery, TResponse>
- Inherited Members
Remarks
You should never directly inherit from this class. Use QueryHandlerBase<TQuery, TResponse> or CommandHandlerBase<TCommand, TResponse> instead
Constructors
RequestHandlerBase()
protected RequestHandlerBase()
Methods
BadRequest(string?, IDictionary<string, string[]>?)
Returns a 400 - bad request error with optional error message and field specific validation errors
public IHandlerResult BadRequest(string? errorMessage = null, IDictionary<string, string[]>? validationErrors = null)
Parameters
errorMessagestringThe optional error message.
validationErrorsIDictionary<string, string[]>The optional field-specific validation errors.
Returns
- IHandlerResult
A IHandlerResult representing a 400 - bad request error.
BadRequest(TResponse?, string?, IDictionary<string, string[]>?)
Returns a 400 - bad request error with optional response object TResponse, error message and
field specific validation errors
public IHandlerResult BadRequest(TResponse? response, string? errorMessage = null, IDictionary<string, string[]>? validationErrors = null)
Parameters
responseTResponseThe optional response object.
errorMessagestringThe optional error message.
validationErrorsIDictionary<string, string[]>The optional field-specific validation errors.
Returns
- IHandlerResult
A IHandlerResult representing a 400 - bad request error.
Cancel()
Creates a handler result indicating that the event processing has been canceled.
public IHandlerResult Cancel()
Returns
- IHandlerResult
A IHandlerResult indicating an error with status code GatewayTimeout.
Error(int, TResponse?, string?, IDictionary<string, string[]>?)
Returns a response with the given status code with optional response object TResponse, error
message and
field specific validation errors
public IHandlerResult Error(int statusCode, TResponse? response = null, string? errorMessage = null, IDictionary<string, string[]>? validationErrors = null)
Parameters
statusCodeintThe HTTP status code for the error response.
responseTResponseThe optional response object.
errorMessagestringThe optional error message.
validationErrorsIDictionary<string, string[]>The optional field-specific validation errors.
Returns
- IHandlerResult
A IHandlerResult representing an error response with the specified status code.
Error(string?, IDictionary<string, string[]>?)
Returns a 500 - internal server error with optional error message and field specific validation errors
public IHandlerResult Error(string? errorMessage = null, IDictionary<string, string[]>? validationErrors = null)
Parameters
errorMessagestringThe optional error message.
validationErrorsIDictionary<string, string[]>The optional field-specific validation errors.
Returns
- IHandlerResult
A IHandlerResult representing a 500 - internal server error.
Error(TResponse?, string?, IDictionary<string, string[]>?)
Returns a 500 - internal server error with optional response object TResponse, error message
and field specific validation errors
public IHandlerResult Error(TResponse? response, string? errorMessage = null, IDictionary<string, string[]>? validationErrors = null)
Parameters
responseTResponseThe optional response object of type
TResponse.errorMessagestringThe optional error message.
validationErrorsIDictionary<string, string[]>The optional field-specific validation errors.
Returns
- IHandlerResult
A IHandlerResult representing a 500 - internal server error.
Ok(TResponse)
Creates a handler result indicating that the event processing is successful.
The message will be acked and the TResponse will be sent.
public IHandlerResult Ok(TResponse response)
Parameters
responseTResponse