Table of Contents

Class RequestHandlerBase<TRequest, TResponse>

Namespace
CarrotMQ.Core.Handlers
Assembly
CarrotMQ.Core.dll
public abstract class RequestHandlerBase<TRequest, TResponse> : HandlerBase<TRequest, TResponse> where TRequest : _IRequest<TRequest, TResponse> where TResponse : class

Type Parameters

TRequest

The type of the request being handled.

TResponse

The 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

errorMessage string

The optional error message.

validationErrors IDictionary<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

response TResponse

The optional response object.

errorMessage string

The optional error message.

validationErrors IDictionary<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

statusCode int

The HTTP status code for the error response.

response TResponse

The optional response object.

errorMessage string

The optional error message.

validationErrors IDictionary<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

errorMessage string

The optional error message.

validationErrors IDictionary<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

response TResponse

The optional response object of type TResponse.

errorMessage string

The optional error message.

validationErrors IDictionary<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

response TResponse

Returns

IHandlerResult