FG.MiddlewareCollection
1.0.0
See the version list below for details.
dotnet add package FG.MiddlewareCollection --version 1.0.0
NuGet\Install-Package FG.MiddlewareCollection -Version 1.0.0
<PackageReference Include="FG.MiddlewareCollection" Version="1.0.0" />
paket add FG.MiddlewareCollection --version 1.0.0
#r "nuget: FG.MiddlewareCollection, 1.0.0"
// Install FG.MiddlewareCollection as a Cake Addin #addin nuget:?package=FG.MiddlewareCollection&version=1.0.0 // Install FG.MiddlewareCollection as a Cake Tool #tool nuget:?package=FG.MiddlewareCollection&version=1.0.0
FG.MiddlewareCollection
Overview
FG.MiddlewareCollection is a .NET library providing a robust collection of middleware for enhancing your ASP.NET Core application's request pipeline. It simplifies the integration of common functionalities like logging, error handling, rate limiting, and more.
Features
- Advanced request and error logging
- Configurable CORS and rate limiting
- Circuit breaker for fault tolerance
- IP whitelisting and blacklisting
- Middleware for response compression, XSS protection, and health checks
Installation
Install the package via NuGet:
Install-Package FG.MiddlewareCollection
Usage
Here are some examples demonstrating how to use the middleware in your ASP.NET Core application:
Advanced Logging Middleware
app.UseAdvancedLogging();
Error Logging Middleware
app.UseErrorLogging();
Health Check Middleware
app.UseHealthCheck();
Response Compression Middleware
app.UseResponseCompression();
IP Blacklisting Middleware
var blacklistedIPs = new[] { "192.168.1.1", "10.0.0.1" };
app.UseIPBlacklisting(services, blacklistedIPs);
IP Whitelisting Middleware
var whitelistedIPs = new[] { "192.168.1.2", "10.0.0.2" };
app.UseIPWhitelisting(services, whitelistedIPs);
Circuit Breaker Middleware
Using Options
var circuitBreakerOptions = new CircuitBreakerMiddlewareOptions
{
Threshold = 5,
OpenTime = TimeSpan.FromSeconds(30)
};
app.UseCircuitBreaker(services, circuitBreakerOptions);
Using Configuration
app.UseCircuitBreaker(services, configuration);
Rate Limiting Middleware
Simple Configuration
app.UseRateLimiting(services, rateLimitPerMinute: 100, limitExceedErrorMessage: "Too many requests. Try again later.");
Using Configuration
app.UseRateLimiting(services, configuration);
Using Options
var rateLimitingOptions = new RateLimitingMiddlewareOptions
{
RequestsPerMinute = 200,
LimitExceedErrorMessage = "You have exceeded the rate limit."
};
app.UseRateLimiting(services, rateLimitingOptions);
Cross-Origin Resource Sharing (CORS) Middleware
With Custom Options
var corsOptions = new CorsMiddlewareOptions
{
AllowOrigin = "*" ,
AllowMethods = "GET, POST",
AllowHeaders = "Content-Type, Authorization"
};
app.UseCors(services, corsOptions);
Using Configuration
app.UseCors(services, configuration);
XSS Protection Middleware
app.UseXssProtection();
Contributing
We welcome contributions! Please check the contributing guidelines for more details.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- Microsoft.IdentityModel.Tokens (>= 8.3.0)
- System.IdentityModel.Tokens.Jwt (>= 8.3.0)
- System.Text.Json (>= 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.