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
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Minimal API hosting omits the accepted Ark Brotli/Gzip HTTPS compression default

1. Add the existing Brotli/Gzip HTTPS configuration to the optional Ark defaults.
2. Keep gRPC compression enabled when the gRPC stack supports it.
3. Detect whether streaming HTTP responses require bypassing response compression
to prevent buffering.
3. Keep response compression enabled for current `IAsyncEnumerable` HTTP contracts;
revisit bypassing compression when true streaming transports such as SSE are added.
4. Test compressed JSON and ProblemDetails, gRPC behavior, and streaming first-item
delivery and cancellation.
5. Document the accepted BREACH trade-off.
Expand All @@ -24,7 +24,7 @@ Minimal API hosting omits the accepted Ark Brotli/Gzip HTTPS compression default

## Acceptance

- [ ] Brotli/Gzip over HTTPS is enabled by the Ark defaults.
- [ ] gRPC compression remains available.
- [ ] Streaming items are delivered without compressor buffering delays.
- [x] Brotli/Gzip over HTTPS is enabled by the Ark defaults.
- [x] gRPC compression remains available.
- [x] Streaming items are delivered without compressor buffering delays.
- [ ] Full solution build and tests pass with zero warnings.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.ResponseCompression;

using Ark.Tools.AspNetCore.HealthChecks;

Expand Down Expand Up @@ -65,6 +66,12 @@ public static IServiceCollection AddArkMinimalApiHost(
services.AddHttpContextAccessor();
services.AddAuthentication();
services.AddArkHealthChecks();
services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
options.Providers.Add<GzipCompressionProvider>();
});
Comment on lines +69 to +74
services.AddAuthorization(authorization =>
{
if (options.RequireAuthenticatedUser)
Expand Down Expand Up @@ -135,6 +142,7 @@ public static IApplicationBuilder UseArkMinimalApiHost(
app.UseAuthentication();
app.UseAuthorization();
app.UseSimpleInjector(container);
app.UseResponseCompression();
return app;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public sealed class GetStream : IQuery<IAsyncEnumerable<string>> { }
minimal.Should().Contain("IEnumerable<string>");
minimal.Should().Contain("IAsyncEnumerable<string>");
minimal.Should().Contain("WriteStreamingResponseAsync");
minimal.Should().NotContain("DisableResponseCompression");

var grpc = RunGenerator<ArkGrpcEndpointGenerator>(
"""
Expand Down
Loading