Skip to content

Instantly share code, notes, and snippets.

View AlexanderReaper7's full-sized avatar
🤖

Alexander Öberg AlexanderReaper7

🤖
  • Sweden
  • 22:06 (UTC +01:00)
View GitHub Profile
@AlexanderReaper7
AlexanderReaper7 / MediatRLogger.cs
Last active May 30, 2024 17:10
C# ASP.NET MediatR logger and validator for ErrorOr requests
using ErrorOr;
using global::MediatR;
/// <summary>
/// A logging behavior for MediatR. Logs the request and any exceptions that occur.
/// </summary>
public class MediatRLoggerIErrorOr<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : notnull
where TResponse : IErrorOr
{