Skip to content

Commit af2973c

Browse files
committed
docs: update README Getting Started
1 parent 1c3dafc commit af2973c

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

README.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,20 @@ Here's an example of how to use `LocalPortFiltering` in an ASP.NET Core applicat
2323
```csharp
2424
var builder = WebApplication.CreateBuilder(args);
2525

26-
// Register services
27-
builder.Services.AddLogging();
28-
builder.Services.AddControllers();
29-
builder.Services.AddEndpointsApiExplorer();
30-
builder.Services.AddSwaggerGen();
31-
builder.Services.AddHealthChecks();
32-
builder.Services.AddLocalPortFiltering(options =>
33-
{
34-
options.IncludeFailureMessage = true; // Enable failure message
35-
});
26+
// Add LocalPortFiltering service
27+
builder.Services.AddLocalPortFiltering();
3628

3729
var app = builder.Build();
3830

39-
// Configure middleware
40-
app.UseSwagger();
41-
app.UseSwaggerUI();
42-
app.UseWhen(context => context.Connection.LocalPort == 5099,
43-
appBuilder => appBuilder.UseHttpsRedirection());
44-
app.UseAuthorization();
31+
// Use LocalPortFiltering middleware
4532
app.UseLocalPortFiltering();
4633

47-
// Configure endpoints
48-
app.MapHealthChecks("/healthz").RequireLocalPortFiltering(allowPort: 5105);
49-
app.MapControllers();
34+
// Define a GET endpoint with port filtering
35+
app.MapGet("/service1", () => "Welcome to Service 1")
36+
.RequireLocalPortFiltering(allowPort: 5105);
37+
38+
// Define another GET endpoint without port filtering
39+
app.MapGet("/service2", () => "Welcome to Service 2");
5040

5141
app.Run();
5242
```

0 commit comments

Comments
 (0)