Browse Source

Just some formatting and unification.

pull/484/head
Sebastian 6 years ago
parent
commit
0f308a8e58
  1. 2
      backend/src/Squidex.Web/CommandMiddlewares/ETagCommandMiddleware.cs
  2. 3
      backend/src/Squidex.Web/CommandMiddlewares/EnrichWithActorCommandMiddleware.cs
  3. 2
      backend/src/Squidex.Web/CommandMiddlewares/EnrichWithAppIdCommandMiddleware.cs
  4. 3
      backend/src/Squidex.Web/CommandMiddlewares/EnrichWithSchemaIdCommandMiddleware.cs
  5. 3
      backend/src/Squidex.Web/FileCallbackResult.cs
  6. 5
      backend/src/Squidex.Web/Pipeline/ActionContextLogAppender.cs
  7. 11
      backend/src/Squidex.Web/Pipeline/ApiCostsFilter.cs
  8. 3
      backend/src/Squidex.Web/Pipeline/AppResolver.cs
  9. 4
      backend/src/Squidex.Web/Pipeline/CachingFilter.cs
  10. 3
      backend/src/Squidex.Web/Pipeline/CleanupHostMiddleware.cs
  11. 11
      backend/src/Squidex.Web/Pipeline/EnforceHttpsMiddleware.cs
  12. 13
      backend/src/Squidex.Web/Pipeline/RequestLogPerformanceMiddleware.cs
  13. 4
      backend/src/Squidex.Web/Services/UrlGenerator.cs
  14. 2
      backend/tests/Squidex.Web.Tests/Pipeline/ApiCostsFilterTests.cs

2
backend/src/Squidex.Web/CommandMiddlewares/ETagCommandMiddleware.cs

@ -22,6 +22,8 @@ namespace Squidex.Web.CommandMiddlewares
public ETagCommandMiddleware(IHttpContextAccessor httpContextAccessor)
{
Guard.NotNull(httpContextAccessor);
this.httpContextAccessor = httpContextAccessor;
}

3
backend/src/Squidex.Web/CommandMiddlewares/EnrichWithActorCommandMiddleware.cs

@ -9,6 +9,7 @@ using System.Security;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Squidex.Domain.Apps.Entities;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Security;
@ -20,6 +21,8 @@ namespace Squidex.Web.CommandMiddlewares
public EnrichWithActorCommandMiddleware(IHttpContextAccessor httpContextAccessor)
{
Guard.NotNull(httpContextAccessor);
this.httpContextAccessor = httpContextAccessor;
}

2
backend/src/Squidex.Web/CommandMiddlewares/EnrichWithAppIdCommandMiddleware.cs

@ -20,6 +20,8 @@ namespace Squidex.Web.CommandMiddlewares
public EnrichWithAppIdCommandMiddleware(IContextProvider contextProvider)
{
Guard.NotNull(contextProvider);
this.contextProvider = contextProvider;
}

3
backend/src/Squidex.Web/CommandMiddlewares/EnrichWithSchemaIdCommandMiddleware.cs

@ -23,6 +23,9 @@ namespace Squidex.Web.CommandMiddlewares
public EnrichWithSchemaIdCommandMiddleware(IAppProvider appProvider, IActionContextAccessor actionContextAccessor)
{
Guard.NotNull(appProvider);
Guard.NotNull(actionContextAccessor);
this.appProvider = appProvider;
this.actionContextAccessor = actionContextAccessor;

3
backend/src/Squidex.Web/FileCallbackResult.cs

@ -10,6 +10,7 @@ using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Squidex.Infrastructure;
using Squidex.Web.Pipeline;
namespace Squidex.Web
@ -23,6 +24,8 @@ namespace Squidex.Web
public FileCallbackResult(string contentType, string? name, bool send404, Func<Stream, Task> callback)
: base(contentType)
{
Guard.NotNull(callback);
FileDownloadName = name;
Send404 = send404;

5
backend/src/Squidex.Web/Pipeline/ActionContextLogAppender.cs

@ -9,6 +9,7 @@ using System;
using System.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Log;
namespace Squidex.Web.Pipeline
@ -20,7 +21,11 @@ namespace Squidex.Web.Pipeline
public ActionContextLogAppender(IActionContextAccessor actionContextAccessor, IHttpContextAccessor httpContextAccessor)
{
Guard.NotNull(actionContextAccessor);
Guard.NotNull(httpContextAccessor);
this.actionContextAccessor = actionContextAccessor;
this.httpContextAccessor = httpContextAccessor;
}

11
backend/src/Squidex.Web/Pipeline/ApiCostsFilter.cs

@ -26,14 +26,19 @@ namespace Squidex.Web.Pipeline
private readonly IUsageTracker usageTracker;
private readonly IClock clock;
public ApiCostsFilter(IAppLogStore appLogStore, IAppPlansProvider appPlansProvider, IClock clock, IUsageTracker usageTracker)
public ApiCostsFilter(IAppLogStore appLogStore, IAppPlansProvider appPlansProvider, IUsageTracker usageTracker, IClock clock)
{
Guard.NotNull(appLogStore);
Guard.NotNull(appPlansProvider);
Guard.NotNull(usageTracker);
Guard.NotNull(clock);
this.appLogStore = appLogStore;
this.appPlansProvider = appPlansProvider;
this.clock = clock;
this.usageTracker = usageTracker;
this.clock = clock;
}
IFilterMetadata IFilterContainer.FilterDefinition { get; set; }

3
backend/src/Squidex.Web/Pipeline/AppResolver.cs

@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Squidex.Domain.Apps.Entities;
using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Security;
using Squidex.Shared;
using Squidex.Shared.Identity;
@ -25,6 +26,8 @@ namespace Squidex.Web.Pipeline
public AppResolver(IAppProvider appProvider)
{
Guard.NotNull(appProvider);
this.appProvider = appProvider;
}

4
backend/src/Squidex.Web/Pipeline/CachingFilter.cs

@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
using Squidex.Infrastructure;
namespace Squidex.Web.Pipeline
{
@ -22,6 +23,9 @@ namespace Squidex.Web.Pipeline
public CachingFilter(CachingManager cachingManager, IOptions<CachingOptions> cachingOptions)
{
Guard.NotNull(cachingManager);
Guard.NotNull(cachingOptions);
this.cachingOptions = cachingOptions.Value;
this.cachingManager = cachingManager;
}

3
backend/src/Squidex.Web/Pipeline/CleanupHostMiddleware.cs

@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Squidex.Infrastructure;
namespace Squidex.Web.Pipeline
{
@ -16,6 +17,8 @@ namespace Squidex.Web.Pipeline
public CleanupHostMiddleware(RequestDelegate next)
{
Guard.NotNull(next);
this.next = next;
}

11
backend/src/Squidex.Web/Pipeline/EnforceHttpsMiddleware.cs

@ -9,21 +9,24 @@ using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Squidex.Infrastructure;
namespace Squidex.Web.Pipeline
{
public sealed class EnforceHttpsMiddleware : IMiddleware
{
private readonly UrlsOptions urls;
private readonly UrlsOptions urlsOptions;
public EnforceHttpsMiddleware(IOptions<UrlsOptions> urls)
public EnforceHttpsMiddleware(IOptions<UrlsOptions> urlsOptions)
{
this.urls = urls.Value;
Guard.NotNull(urlsOptions);
this.urlsOptions = urlsOptions.Value;
}
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
if (!urls.EnforceHTTPS)
if (!urlsOptions.EnforceHTTPS)
{
await next(context);
}

13
backend/src/Squidex.Web/Pipeline/RequestLogPerformanceMiddleware.cs

@ -16,12 +16,15 @@ namespace Squidex.Web.Pipeline
{
public sealed class RequestLogPerformanceMiddleware : IMiddleware
{
private readonly RequestLogOptions options;
private readonly RequestLogOptions requestLogOptions;
private readonly ISemanticLog log;
public RequestLogPerformanceMiddleware(IOptions<RequestLogOptions> options, ISemanticLog log)
public RequestLogPerformanceMiddleware(IOptions<RequestLogOptions> requestLogOptions, ISemanticLog log)
{
this.options = options.Value;
Guard.NotNull(requestLogOptions);
Guard.NotNull(log);
this.requestLogOptions = requestLogOptions.Value;
this.log = log;
}
@ -40,11 +43,11 @@ namespace Squidex.Web.Pipeline
{
var elapsedMs = watch.Stop();
if (options.LogRequests)
if (requestLogOptions.LogRequests)
{
log.LogInformation((elapsedMs, context), (ctx, w) =>
{
if (options.LogProfiler)
if (requestLogOptions.LogProfiler)
{
Profiler.Session?.Write(w);
}

4
backend/src/Squidex.Web/Services/UrlGenerator.cs

@ -29,7 +29,11 @@ namespace Squidex.Web.Services
public UrlGenerator(IOptions<UrlsOptions> urlsOptions, IAssetFileStore assetFileStore, bool allowAssetSourceUrl)
{
Guard.NotNull(assetFileStore);
Guard.NotNull(urlsOptions);
this.assetFileStore = assetFileStore;
this.urlsOptions = urlsOptions.Value;
CanGenerateAssetSourceUrl = allowAssetSourceUrl;

2
backend/tests/Squidex.Web.Tests/Pipeline/ApiCostsFilterTests.cs

@ -70,7 +70,7 @@ namespace Squidex.Web.Pipeline
return Task.FromResult<ActionExecutedContext?>(null);
};
sut = new ApiCostsFilter(appLogStore, appPlansProvider, clock, usageTracker);
sut = new ApiCostsFilter(appLogStore, appPlansProvider, usageTracker, clock);
}
[Fact]

Loading…
Cancel
Save