diff --git a/src/Imageflow.Server/ImageflowMiddleware.cs b/src/Imageflow.Server/ImageflowMiddleware.cs index 98c5a2b..60f8ce5 100644 --- a/src/Imageflow.Server/ImageflowMiddleware.cs +++ b/src/Imageflow.Server/ImageflowMiddleware.cs @@ -55,16 +55,14 @@ public ImageflowMiddleware( globalInfoProvider = new GlobalInfoProvider(container); container.Register(globalInfoProvider); - var licensingOptions = new LicenseOptions() - { CandidateCacheFolders = new[] { env.ContentRootPath, Path.GetTempPath() } }; + - container.Register(licensingOptions); container.Register(env); container.Register(logger); - new MiddlewareOptionsServerBuilder(container, logger, retainedLogStore, options, env).PopulateServices(); + new MiddlewareOptionsServerBuilder(container, logger, retainedLogStore, options,env).PopulateServices(); var startDiag = new StartupDiagnostics(container); diff --git a/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs b/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs index f5ca6fa..f8ba980 100644 --- a/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs +++ b/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs @@ -56,6 +56,21 @@ public void PopulateServices() serverContainer.Register(perfTracker); + var licensingOptions = new LicenseOptions + { + LicenseKey = options.LicenseKey, + MyOpenSourceProjectUrl = options.MyOpenSourceProjectUrl, + KeyPrefix = "imageflow_", + CandidateCacheFolders = new[] + { + env.ContentRootPath, + Path.GetTempPath() + }, + EnforcementMethod = Imazen.Routing.Layers.EnforceLicenseWith.RedDotWatermark, + + }; + serverContainer.Register(licensingOptions); + var diagPageOptions = new DiagnosticsPageOptions( options.DiagnosticsPassword, (Imazen.Routing.Layers.DiagnosticsPageOptions.AccessDiagnosticsFrom)options.DiagnosticsAccess); @@ -106,11 +121,12 @@ public void PopulateServices() var routingEngine = router.Build(logger); serverContainer.Register(routingEngine); + //TODO: Add a way to get the current ILicenseChecker var imageServer = new ImageServer( serverContainer, - null, + licensingOptions, routingEngine, perfTracker, logger); serverContainer.Register>(imageServer); diff --git a/src/Imazen.Routing/Layers/IRoutingEndpoint.cs b/src/Imazen.Routing/Layers/IRoutingEndpoint.cs index fcd458e..7ad08fb 100644 --- a/src/Imazen.Routing/Layers/IRoutingEndpoint.cs +++ b/src/Imazen.Routing/Layers/IRoutingEndpoint.cs @@ -8,7 +8,7 @@ namespace Imazen.Routing.Layers; public interface IRoutingEndpoint { bool IsBlobEndpoint { get; } - //ValueTask> GetInstantPromise(IRequestSnapshot request, CancellationToken cancellationToken = default); + ValueTask GetInstantPromise(IRequestSnapshot request, CancellationToken cancellationToken = default); } diff --git a/src/Imazen.Routing/Layers/Licensing.cs b/src/Imazen.Routing/Layers/Licensing.cs index f7e5e66..dea6135 100644 --- a/src/Imazen.Routing/Layers/Licensing.cs +++ b/src/Imazen.Routing/Layers/Licensing.cs @@ -6,10 +6,10 @@ namespace Imageflow.Server { public class LicenseOptions{ - internal string LicenseKey { get; set; } = ""; + internal string? LicenseKey { get; set; } = ""; internal string MyOpenSourceProjectUrl { get; set; } = ""; - internal string KeyPrifx { get; set; } = "imageflow_"; + internal string KeyPrefix { get; set; } = "imageflow_"; public required string[] CandidateCacheFolders { get; set; } internal EnforceLicenseWith EnforcementMethod { get; set; } = EnforceLicenseWith.RedDotWatermark; diff --git a/src/Imazen.Routing/Serving/ImageServer.cs b/src/Imazen.Routing/Serving/ImageServer.cs index ac16f95..3c7b732 100644 --- a/src/Imazen.Routing/Serving/ImageServer.cs +++ b/src/Imazen.Routing/Serving/ImageServer.cs @@ -51,7 +51,7 @@ public ImageServer(IImageServerContainer container, licenseChecker = container.GetService() ?? new Licensing(LicenseManagerSingleton.GetOrCreateSingleton( - licenseOptions.KeyPrifx, licenseOptions.CandidateCacheFolders), null); + licenseOptions.KeyPrefix, licenseOptions.CandidateCacheFolders), null); licenseChecker.Initialize(licenseOptions); licenseChecker.FireHeartbeat();