Class OriginValidationBehaviour<TMessage>
Validates the origin of an incoming message by checking a configurable header
against the AllowedOriginAttribute applied on the message type.
This behavior is automatically registered when AddChaparPipeline is called.
Implements
IPipelineBehavior<TMessage>
Inherited Members
Namespace: Chapar.Pipeline.Behaviours
Assembly: Chapar.Pipeline.dll
Syntax
public sealed class OriginValidationBehaviour<TMessage> : IPipelineBehavior<TMessage> where TMessage : IMessage
Type Parameters
| Name | Description |
|---|---|
| TMessage | The type of the message being handled. |
Constructors
| Edit this page View SourceOriginValidationBehaviour(ILogger<OriginValidationBehaviour<TMessage>>, IMessageContextAccessor?, string)
Initializes a new instance of the OriginValidationBehaviour<TMessage> class.
Declaration
public OriginValidationBehaviour(ILogger<OriginValidationBehaviour<TMessage>> logger, IMessageContextAccessor? contextAccessor = null, string headerName = "Origin")
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<OriginValidationBehaviour<TMessage>> | logger | The logger instance. |
| IMessageContextAccessor | contextAccessor | An optional accessor to read message headers. |
| string | headerName | The header key to check for origin. Default is "Origin". |
Methods
| Edit this page View SourceHandleAsync(TMessage, Func<Task>, CancellationToken)
Executes the behaviour and optionally calls the next delegate in the pipeline.
Declaration
public Task HandleAsync(TMessage message, Func<Task> next, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| TMessage | message | The message to process. |
| Func<Task> | next | A delegate representing the next action in the pipeline. |
| CancellationToken | cancellationToken | Token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task |