Skip to content

Commit

Permalink
feat: enable Brotli response compression (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Orlov authored Nov 9, 2022
1 parent 6e240bf commit 6802c3d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion VirtoCommerce.Storefront/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.IO.Compression;
using FluentValidation.AspNetCore;
using GraphQL.Client.Abstractions;
using GraphQL.Client.Http;
Expand All @@ -21,6 +22,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.WebEncoders;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
Expand Down Expand Up @@ -326,7 +328,13 @@ public void ConfigureServices(IServiceCollection services)
c.CustomSchemaIds(type => (Attribute.GetCustomAttribute(type, typeof(SwaggerSchemaIdAttribute)) as SwaggerSchemaIdAttribute)?.Id ?? type.FriendlyId());
});

services.AddResponseCompression();
services.Configure<BrotliCompressionProviderOptions>(options => {
options.Level = CompressionLevel.Optimal;
});
services.AddResponseCompression(options => {
options.EnableForHttps = true;
options.Providers.Add<BrotliCompressionProvider>();
});

services.AddProxy(builder => builder.AddHttpMessageHandler(sp => sp.GetService<AuthenticationHandlerFactory>().CreateAuthHandler()));

Expand Down

0 comments on commit 6802c3d

Please sign in to comment.