Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DebugProbe.AspNetCore/DebugProbe.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>

<PackageId>DebugProbe.AspNetCore</PackageId>
<Version>1.4.1-preview.2</Version>
Expand Down
15 changes: 10 additions & 5 deletions DebugProbe.AspNetCore/Extensions/DebugProbeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@

namespace DebugProbe.AspNetCore.Extensions;

/// <summary>
/// Extension methods for configuring DebugProbe.
/// </summary>
public static class DebugProbeExtensions
{
private static readonly HttpClient Http = new()
{
Timeout = TimeSpan.FromSeconds(5)
};

public static IServiceCollection AddDebugProbe(
this IServiceCollection services,
Action<DebugProbeOptions>? configure = null)
/// <summary>
/// Enables the DebugProbe middleware and dashboard.
/// </summary>
public static IServiceCollection AddDebugProbe(this IServiceCollection services, Action<DebugProbeOptions>? configure = null)
{
var options = new DebugProbeOptions();
configure?.Invoke(options);
Expand All @@ -33,6 +37,9 @@ public static IServiceCollection AddDebugProbe(
return services;
}

/// <summary>
/// Registers DebugProbe services.
/// </summary>
public static IApplicationBuilder UseDebugProbe(this IApplicationBuilder app)
{
app.UseMiddleware<DebugProbeMiddleware>();
Expand Down Expand Up @@ -188,6 +195,4 @@ public static IApplicationBuilder UseDebugProbe(this IApplicationBuilder app)

return app;
}


}
6 changes: 6 additions & 0 deletions DebugProbe.AspNetCore/Middleware/DebugProbeMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@ public class DebugProbeMiddleware
private readonly RequestDelegate _next;
private readonly DebugProbeOptions _options;

/// <summary>
/// Initializes a new instance of the middleware.
/// </summary>
public DebugProbeMiddleware(RequestDelegate next, DebugProbeOptions options)
{
_next = next;
_options = options;
}

/// <summary>
/// Processes the current HTTP request.
/// </summary>
public async Task Invoke(HttpContext context, DebugEntryStore store)
{
var path = context.Request.Path.Value ?? string.Empty;
Expand Down
16 changes: 15 additions & 1 deletion DebugProbe.AspNetCore/Options/DebugProbeOptions.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
namespace DebugProbe.AspNetCore.Options;

/// <summary>
/// Configuration options for DebugProbe.
/// </summary>
public class DebugProbeOptions
{
/// <summary>
/// Maximum number of stored entries.
/// </summary>
public int MaxEntries { get; set; } = 20;

/// <summary>
/// Maximum captured request or response body size in kilobytes.
/// </summary>
public int MaxBodyCaptureSizeKb { get; set; } = 256;

/// <summary>
/// Allows compare requests to local or private network targets.
/// </summary>
public bool AllowLocalCompareTargets { get; set; }

/// <summary>
/// Additional request paths to ignore.
/// </summary>
public string[] IgnorePaths { get; set; } = [];

}
6 changes: 5 additions & 1 deletion DebugProbe.AspNetCore/Storage/DebugEntryStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
namespace DebugProbe.AspNetCore.Storage;

/// <summary>
/// In-memory store for DebugEntry instances with a configurable size limit.
/// Stores captured DebugProbe entries in memory.
/// </summary>
public class DebugEntryStore
{
/// <summary>
/// Gets environment information for the current application.
/// </summary>
public DebugEnvironment Environment { get; }

private readonly ConcurrentQueue<DebugEntry> _queue = new();
private readonly int _limit;


public DebugEntryStore(DebugProbeOptions options)
{
_limit = options.MaxEntries;
Expand Down
Loading