Caravel.MediatR
0.21.0
dotnet add package Caravel.MediatR --version 0.21.0
NuGet\Install-Package Caravel.MediatR -Version 0.21.0
<PackageReference Include="Caravel.MediatR" Version="0.21.0" />
<PackageVersion Include="Caravel.MediatR" Version="0.21.0" />
<PackageReference Include="Caravel.MediatR" />
paket add Caravel.MediatR --version 0.21.0
#r "nuget: Caravel.MediatR, 0.21.0"
#addin nuget:?package=Caravel.MediatR&version=0.21.0
#tool nuget:?package=Caravel.MediatR&version=0.21.0
Caravel.MediatR
This package contains reusable MediatR behaviours.
Logging Pipeline Behaviour
Creates an entry Log for the start and failure of each request in the pipeline. It will log the error in case the request fails.
builder.Services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddOpenBehavior(typeof(LoggingPipelineBehaviour<,>));
});
Validation Pipeline Behaviour
Validates requests using FluentValidation. This behaviour detects via reflection if the Response is using the Result
pattern to avoid throwing unnecessary ValidationException
, if not then throws it.
builder.Services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddOpenBehavior(typeof(ValidationPipelineBehaviour<,>));
});
{
"code": "invalid_fields",
"title": "Invalid Fields",
"status": 400,
"errors": {
"field1": ["error_1", "error_2"]
}
}
Idempotent Pipeline Behaviour
Ensures all requests implementing interface IIdempotentRequest
are idempotent.
builder.Services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddOpenBehavior(typeof(IdempotentPipelineBehaviour<,>));
});
{
"code": "duplicate_request",
"title": "Duplicate request",
"status": 204,
"detail": "Duplicate request with Idempotent Key 53655b3d-48d5-4ac1-ba73-4318b3b702e8."
}
Caching Pipeline Behaviour
Caches responses where the request implements ICachedQuery
.
// Requires implementing the caching service.
builder.Services.AddSingleton<ICacheService, CacheService>();
builder.Services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddOpenBehavior(typeof(CachingPipelineBehavior<,>));
});
{
"code": "duplicate_request",
"title": "Duplicate request",
"status": 204,
"detail": "Duplicate request with Idempotent Key 53655b3d-48d5-4ac1-ba73-4318b3b702e8."
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Caravel (>= 0.33.0)
- FluentValidation (>= 11.11.0)
- MediatR (>= 12.4.1)
- Microsoft.Extensions.Logging (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.21.0 | 314 | 12/6/2024 |
0.20.0 | 241 | 10/12/2024 |
0.19.0 | 156 | 10/2/2024 |
0.18.0 | 126 | 9/29/2024 |
0.17.0 | 103 | 9/28/2024 |
0.16.0 | 127 | 8/20/2024 |
0.14.0 | 241 | 12/10/2023 |
0.13.0 | 142 | 12/4/2023 |
0.12.0 | 416 | 10/2/2022 |
0.11.0 | 448 | 9/24/2022 |
0.10.0 | 162 | 9/24/2022 |
0.8.0 | 247 | 9/30/2021 |
0.7.0 | 239 | 9/27/2021 |
0.6.0 | 399 | 4/10/2021 |
0.5.0 | 448 | 11/21/2020 |
0.4.0 | 474 | 11/15/2020 |
0.3.0 | 456 | 10/27/2020 |
0.2.0 | 509 | 10/12/2020 |
0.1.1 | 471 | 9/5/2020 |
0.1.0 | 510 | 9/5/2020 |