RA.Utilities.Api.Middlewares
This package is deprecated and has been moved to RA.Utilities.Api.
All middleware types are now available in the RA.Utilities.Api package with expanded features — including multi-header enforcement, log-scope enrichment, and header filtering. See the RA.Utilities.Api middlewares documentation for the current API and migration instructions.
RA.Utilities.Api.Middlewares provides a collection of useful ASP.NET Core middlewares designed to improve diagnostics and enforce API best practices.
This package includes middlewares for efficient HTTP request/response logging and for ensuring the presence of default required headers.
🎯 Purpose
This package aims to solve common cross-cutting concerns in API development:
- HTTP Request/Response Logging: Provides a highly performant middleware to log detailed information about incoming requests and their corresponding responses.
It uses
Microsoft.IO.RecyclableMemoryStreamto minimize memory allocations, making it suitable for high-throughput applications. - Header Enforcement: Includes a middleware to validate the presence of essential headers, such as
X-Request-Id, to ensure traceability and consistency across your services.
🛠️ Installation
You can install the package via the .NET CLI:
dotnet add package RA.Utilities.Api.Middlewares
Or through the NuGet Package Manager console:
Install-Package RA.Utilities.Api.Middlewares
Or through the NuGet Package Manager in Visual Studio.
🔗 Dependencies
RA.Utilities.ApiRA.Utilities.Core.ConstantsRA.Utilities.Logging.SharedMicrosoft.AspNetCore.AppMicrosoft.IO.RecyclableMemoryStream
The middleware types previously documented here are now part of RA.Utilities.Api — see the Middlewares and Extensions sections for the current API.
DefaultHeadersMiddleware
The DefaultHeadersMiddleware is a piece of ASP.NET Core middleware designed to enforce API best practices by ensuring that every incoming request includes a specific, mandatory header: X-Request-Id.
HttpLoggingMiddleware
The HttpLoggingMiddleware is a high-performance ASP.NET Core middleware designed to provide comprehensive logging for HTTP requests and responses.
Extensions Methods
2 items