FG.MiddlewareCollection 1.0.4

dotnet add package FG.MiddlewareCollection --version 1.0.4                
NuGet\Install-Package FG.MiddlewareCollection -Version 1.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FG.MiddlewareCollection" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FG.MiddlewareCollection --version 1.0.4                
#r "nuget: FG.MiddlewareCollection, 1.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FG.MiddlewareCollection as a Cake Addin
#addin nuget:?package=FG.MiddlewareCollection&version=1.0.4

// Install FG.MiddlewareCollection as a Cake Tool
#tool nuget:?package=FG.MiddlewareCollection&version=1.0.4                

FG.MiddlewareCollection

NuGet Version

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.4 72 1/20/2025
1.0.1 69 1/13/2025
1.0.0 53 1/8/2025