|
|
@ -7,9 +7,11 @@ |
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks; |
|
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks; |
|
|
using Microsoft.Extensions.Diagnostics.HealthChecks; |
|
|
using Microsoft.Extensions.Diagnostics.HealthChecks; |
|
|
|
|
|
using Microsoft.Extensions.Options; |
|
|
using Microsoft.Net.Http.Headers; |
|
|
using Microsoft.Net.Http.Headers; |
|
|
using Squidex.Infrastructure.Json; |
|
|
using Squidex.Infrastructure.Json; |
|
|
using Squidex.Pipeline.Robots; |
|
|
using Squidex.Pipeline.Robots; |
|
|
|
|
|
using Squidex.Web; |
|
|
using Squidex.Web.Pipeline; |
|
|
using Squidex.Web.Pipeline; |
|
|
|
|
|
|
|
|
namespace Squidex.Config.Web; |
|
|
namespace Squidex.Config.Web; |
|
|
@ -19,14 +21,12 @@ public static class WebExtensions |
|
|
public static IApplicationBuilder UseSquidexCacheKeys(this IApplicationBuilder app) |
|
|
public static IApplicationBuilder UseSquidexCacheKeys(this IApplicationBuilder app) |
|
|
{ |
|
|
{ |
|
|
app.UseMiddleware<CachingKeysMiddleware>(); |
|
|
app.UseMiddleware<CachingKeysMiddleware>(); |
|
|
|
|
|
|
|
|
return app; |
|
|
return app; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseSquidexLocalCache(this IApplicationBuilder app) |
|
|
public static IApplicationBuilder UseSquidexLocalCache(this IApplicationBuilder app) |
|
|
{ |
|
|
{ |
|
|
app.UseMiddleware<LocalCacheMiddleware>(); |
|
|
app.UseMiddleware<LocalCacheMiddleware>(); |
|
|
|
|
|
|
|
|
return app; |
|
|
return app; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -40,28 +40,30 @@ public static class WebExtensions |
|
|
.AddSupportedUICultures(supportedCultures); |
|
|
.AddSupportedUICultures(supportedCultures); |
|
|
|
|
|
|
|
|
app.UseRequestLocalization(localizationOptions); |
|
|
app.UseRequestLocalization(localizationOptions); |
|
|
|
|
|
|
|
|
return app; |
|
|
return app; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseSquidexLogging(this IApplicationBuilder app) |
|
|
public static IApplicationBuilder UseSquidexLogging(this IApplicationBuilder app) |
|
|
{ |
|
|
{ |
|
|
app.UseMiddleware<RequestLogPerformanceMiddleware>(); |
|
|
app.UseMiddleware<RequestLogPerformanceMiddleware>(); |
|
|
|
|
|
|
|
|
return app; |
|
|
return app; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseSquidexUsage(this IApplicationBuilder app) |
|
|
public static IApplicationBuilder UseSquidexUsage(this IApplicationBuilder app) |
|
|
{ |
|
|
{ |
|
|
app.UseMiddleware<UsageMiddleware>(); |
|
|
app.UseMiddleware<UsageMiddleware>(); |
|
|
|
|
|
|
|
|
return app; |
|
|
return app; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseSquidexExceptionHandling(this IApplicationBuilder app) |
|
|
public static IApplicationBuilder UseSquidexExceptionHandling(this IApplicationBuilder app) |
|
|
{ |
|
|
{ |
|
|
app.UseMiddleware<RequestExceptionMiddleware>(); |
|
|
app.UseMiddleware<RequestExceptionMiddleware>(); |
|
|
|
|
|
return app; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseSquidexRobotsTxt(this IApplicationBuilder app) |
|
|
|
|
|
{ |
|
|
|
|
|
app.Map("/robots.txt", builder => builder.UseMiddleware<RobotsTxtMiddleware>()); |
|
|
return app; |
|
|
return app; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -117,19 +119,25 @@ public static class WebExtensions |
|
|
return app; |
|
|
return app; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseSquidexRobotsTxt(this IApplicationBuilder app) |
|
|
public static IApplicationBuilder UseSquidexCors(this IApplicationBuilder app) |
|
|
{ |
|
|
|
|
|
app.Map("/robots.txt", builder => builder.UseMiddleware<RobotsTxtMiddleware>()); |
|
|
|
|
|
|
|
|
|
|
|
return app; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void UseSquidexCors(this IApplicationBuilder app) |
|
|
|
|
|
{ |
|
|
{ |
|
|
app.UseCors(builder => builder |
|
|
app.UseCors(builder => builder |
|
|
.SetIsOriginAllowed(x => true) |
|
|
.SetIsOriginAllowed(x => true) |
|
|
.AllowCredentials() |
|
|
.AllowCredentials() |
|
|
.AllowAnyMethod() |
|
|
.AllowAnyMethod() |
|
|
.AllowAnyHeader()); |
|
|
.AllowAnyHeader()); |
|
|
|
|
|
|
|
|
|
|
|
return app; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static IApplicationBuilder UseSquidexCompression(this IApplicationBuilder app) |
|
|
|
|
|
{ |
|
|
|
|
|
var compressionOptions = app.ApplicationServices.GetRequiredService<IOptions<CompressionOptions>>().Value; |
|
|
|
|
|
if (compressionOptions.Enabled) |
|
|
|
|
|
{ |
|
|
|
|
|
app.UseResponseCompression(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return app; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|