diff --git a/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs b/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs index 13f2bf36..85ae92bf 100644 --- a/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs +++ b/src/Imageflow.Server/Internal/MiddlewareOptionsServerBuilder.cs @@ -7,19 +7,17 @@ using Imazen.Abstractions.DependencyInjection; using Imazen.Abstractions.Logging; using Imazen.Common.Storage; -using Imazen.Routing.Compatibility.ImageflowServer; using Imazen.Routing.Engine; using Imazen.Routing.Health; using Imazen.Routing.HttpAbstractions; using Imazen.Routing.Layers; -using Imazen.Routing.Promises; using Imazen.Routing.Promises.Pipelines; +using Imazen.Routing.Promises.Pipelines.Watermarking; using Imazen.Routing.Requests; using Imazen.Routing.Serving; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Primitives; namespace Imageflow.Server.LegacyOptions; @@ -74,7 +72,7 @@ public void PopulateServices() var match = options.NamedWatermarks.FirstOrDefault(a => name.Equals(a.Name, StringComparison.OrdinalIgnoreCase)); if (match == null) return null; - return new Imazen.Routing.Compatibility.ImageflowServer.WatermarkWithPath( + return new Imazen.Routing.Promises.Pipelines.Watermarking.WatermarkWithPath( match.Name, match.VirtualPath, match.Watermark); diff --git a/src/Imageflow.Server/LegacyOptions/NamedWatermark.cs b/src/Imageflow.Server/LegacyOptions/NamedWatermark.cs index 87a2a22e..65579ee3 100644 --- a/src/Imageflow.Server/LegacyOptions/NamedWatermark.cs +++ b/src/Imageflow.Server/LegacyOptions/NamedWatermark.cs @@ -1,5 +1,5 @@ using Imageflow.Fluent; -using Imazen.Routing.Compatibility.ImageflowServer; +using Imazen.Routing.Promises.Pipelines.Watermarking; using Newtonsoft.Json; namespace Imageflow.Server diff --git a/src/Imageflow.Server/UpdatedUrlEventArgs.cs b/src/Imageflow.Server/UpdatedUrlEventArgs.cs deleted file mode 100644 index 093239db..00000000 --- a/src/Imageflow.Server/UpdatedUrlEventArgs.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Imazen.Routing.Requests; -using Microsoft.Extensions.Primitives; -using Compat = Imazen.Routing.Compatibility.ImageflowServer; - -namespace Imageflow.Server -{ - public class UpdatedUrlEventArgs - { - private readonly Compat.MutableRequestEventArgs inner; - internal UpdatedUrlEventArgs(Compat.MutableRequestEventArgs inner) - { - this.inner = inner; - } - - public string VirtualPath - { - get => inner.VirtualPath; - set => inner.VirtualPath = value; - } - - - public IDictionary Query - { - get => inner.Query; - set => inner.Query = value; - } - - public MutableRequest Request => inner.Request; - } - - -} \ No newline at end of file diff --git a/src/Imazen.Routing/Compatibility/ImageflowServer/ContextUrlEventArgs.cs b/src/Imazen.Routing/Compatibility/ImageflowServer/ContextUrlEventArgs.cs deleted file mode 100644 index a3719d44..00000000 --- a/src/Imazen.Routing/Compatibility/ImageflowServer/ContextUrlEventArgs.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Imazen.Routing.Requests; -using Microsoft.Extensions.Primitives; - -namespace Imazen.Routing.Compatibility.ImageflowServer -{ - internal class ContextUrlEventArgs - { - internal ContextUrlEventArgs(TContext context, string virtualPath, Dictionary query) - { - VirtualPath = virtualPath; - Context = context; - Query = query; - } - - public string VirtualPath { get; set; } - - public Dictionary Query { get; set; } - - public TContext Context { get; } - } - - internal readonly struct MutableRequestEventArgs - { - internal MutableRequestEventArgs(MutableRequest request) - { - Request = request; - } - public string VirtualPath { - get => Request.MutablePath; - set => Request.MutablePath = value; - } - public MutableRequest Request { get; } - - public IDictionary Query { - get => Request.MutableQueryString; - set => Request.MutableQueryString = value; - } - } -} \ No newline at end of file diff --git a/src/Imazen.Routing/Compatibility/ImageflowServer/EnforceLicenseWith.cs b/src/Imazen.Routing/Compatibility/ImageflowServer/EnforceLicenseWith.cs deleted file mode 100644 index 411f91d4..00000000 --- a/src/Imazen.Routing/Compatibility/ImageflowServer/EnforceLicenseWith.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Imazen.Routing.Compatibility.ImageflowServer -{ - internal enum EnforceLicenseWith - { - RedDotWatermark = 0, - Http422Error = 1, - Http402Error = 2 - } -} \ No newline at end of file diff --git a/src/Imazen.Routing/Compatibility/ImageflowServer/ImageflowMiddlewareOptions.cs.txt b/src/Imazen.Routing/Compatibility/ImageflowServer/ImageflowMiddlewareOptions.cs.txt deleted file mode 100644 index cbe84d6c..00000000 --- a/src/Imazen.Routing/Compatibility/ImageflowServer/ImageflowMiddlewareOptions.cs.txt +++ /dev/null @@ -1,77 +0,0 @@ -using Imageflow.Fluent; -using Imazen.Abstractions.Blobs.LegacyProviders; -using Imazen.Common.Storage; -using Imazen.Routing.Compatibility.ImageflowServer.Internal; -using Imazen.Routing.Layers; -using Imazen.Routing.RequestRouting.Layers; - -namespace Imazen.Routing.Compatibility.ImageflowServer -{ - // This type leaks NamedWatermark, RequestSignatureOptions, PathMapping, - // - // And from Imageflow.Net, JobSecurityOptions - - public class ImageflowMiddlewareOptions - { - public bool ApplyDefaultCommandsToQuerylessUrls { get; set; } = false; - public string MyOpenSourceProjectUrl { get; set; } = "https://i-need-a-license.com"; - /// - /// Set to true to allow any registered IStreamCache plugin (such as Imageflow.Server.HybridCache) to be used. - /// - public bool AllowCaching { get; set; } = true; - /// - /// Set to true to allow the legacy disk caching system (Imageflow.Server.DiskCache) to be used - /// - public bool AllowDiskCaching { get; set; } = true; - - public IReadOnlyCollection NamedWatermarks => namedWatermarks; - - public bool UsePresetsExclusively { get; set; } - - public string? DefaultCacheControlString { get; set; } - - public RequestSignatureOptions? RequestSignatureOptions { get; set; } - public SecurityOptions? JobSecurityOptions { get; set; } - public IReadOnlyCollection MappedPaths => mappedPaths; - - public bool MapWebRoot { get; set; } - - - internal string? LicenseKey { get; set; } - internal EnforceLicenseWith EnforcementMethod { get; set; } = EnforceLicenseWith.Http422Error; - - - - protected readonly List namedWatermarks = new List(); - - protected readonly List mappedPaths = new List(); - - - internal AccessDiagnosticsFrom DiagnosticsAccess { get; set; } = AccessDiagnosticsFrom.LocalHost; - - internal string? DiagnosticsPassword { get; set; } - public IReadOnlyCollection BlobProviders { get; set; } - internal IReadOnlyCollection BlobWrapperProviders { get; set; } - - internal readonly List>> Rewrite = new List>>(); - - internal readonly List>> PreRewriteAuthorization = new List>>(); - - internal readonly List>> PostRewriteAuthorization = new List>>(); - - internal readonly List>>> Watermarking = new List>>>(); - - - internal readonly Dictionary CommandDefaults = new Dictionary(StringComparer.OrdinalIgnoreCase); - - internal readonly Dictionary Presets = new Dictionary(StringComparer.OrdinalIgnoreCase); - - internal readonly List ExtensionlessPaths = new List(); - - protected void AddHandleExtensionlessRequestsUnder(string prefix, StringComparison prefixComparison = StringComparison.Ordinal) - { - ExtensionlessPaths.Add(new ExtensionlessPath() { Prefix = prefix, PrefixComparison = prefixComparison}); - - } - } -} \ No newline at end of file diff --git a/src/Imazen.Routing/Compatibility/ImageflowServer/Internal/PathPrefixHandler.cs b/src/Imazen.Routing/Compatibility/ImageflowServer/Internal/PathPrefixHandler.cs deleted file mode 100644 index 933c6929..00000000 --- a/src/Imazen.Routing/Compatibility/ImageflowServer/Internal/PathPrefixHandler.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Imazen.Routing.Compatibility.ImageflowServer.Internal -{ - -} \ No newline at end of file diff --git a/src/Imazen.Routing/Compatibility/ImageflowServer/WatermarkingContextEventArgs.cs b/src/Imazen.Routing/Compatibility/ImageflowServer/WatermarkingContextEventArgs.cs deleted file mode 100644 index 1b3e8b36..00000000 --- a/src/Imazen.Routing/Compatibility/ImageflowServer/WatermarkingContextEventArgs.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.ObjectModel; - -namespace Imazen.Routing.Compatibility.ImageflowServer -{ - internal class WatermarkingContextEventArgs - { - - internal WatermarkingContextEventArgs(TContext context, string virtualPath, Dictionary query, - List watermarks) - { - VirtualPath = virtualPath; - Context = context; - Query = new ReadOnlyDictionary(query); - AppliedWatermarks = watermarks; - } - - //public ImageflowRoute Route { get; set; } - public string VirtualPath { get; } - - public IReadOnlyDictionary Query { get; } - - public List AppliedWatermarks { get; set; } - - public TContext Context { get; } - } - -} \ No newline at end of file diff --git a/src/Imazen.Routing/Imazen.Routing.csproj b/src/Imazen.Routing/Imazen.Routing.csproj index 791f7d9a..6f927c28 100644 --- a/src/Imazen.Routing/Imazen.Routing.csproj +++ b/src/Imazen.Routing/Imazen.Routing.csproj @@ -22,4 +22,8 @@ + + + + diff --git a/src/Imazen.Routing/Layers/LicensingLayer.cs b/src/Imazen.Routing/Layers/LicensingLayer.cs index c4bac3e1..09784fec 100644 --- a/src/Imazen.Routing/Layers/LicensingLayer.cs +++ b/src/Imazen.Routing/Layers/LicensingLayer.cs @@ -1,5 +1,5 @@ using Imazen.Abstractions.Resulting; -using Imazen.Routing.Compatibility.ImageflowServer; +using Imazen.Routing.Promises.Pipelines.Watermarking; using Imazen.Routing.Helpers; using Imazen.Routing.HttpAbstractions; using Imazen.Routing.Requests; @@ -7,6 +7,12 @@ namespace Imazen.Routing.Layers; +internal enum EnforceLicenseWith +{ + RedDotWatermark = 0, + Http422Error = 1, + Http402Error = 2 +} internal class LicensingLayer(ILicenseChecker licenseChecker, EnforceLicenseWith enforcementMethod) : IRoutingLayer { public string Name => "Licensing"; diff --git a/src/Imazen.Routing/Layers/MutableRequestEventLayer.cs b/src/Imazen.Routing/Layers/MutableRequestEventLayer.cs index 2aad2d53..849d5557 100644 --- a/src/Imazen.Routing/Layers/MutableRequestEventLayer.cs +++ b/src/Imazen.Routing/Layers/MutableRequestEventLayer.cs @@ -1,7 +1,8 @@ using Imazen.Abstractions.Resulting; -using Imazen.Routing.Compatibility.ImageflowServer; +using Imazen.Routing.Promises.Pipelines.Watermarking; using Imazen.Routing.Helpers; using Imazen.Routing.Requests; +using Microsoft.Extensions.Primitives; namespace Imazen.Routing.Layers; internal class PathPrefixHandler @@ -15,6 +16,24 @@ internal PathPrefixHandler(string prefix, T handler) public T Handler { get; } } + +internal readonly struct MutableRequestEventArgs +{ + internal MutableRequestEventArgs(MutableRequest request) + { + Request = request; + } + public string VirtualPath { + get => Request.MutablePath; + set => Request.MutablePath = value; + } + public MutableRequest Request { get; } + + public IDictionary Query { + get => Request.MutableQueryString; + set => Request.MutableQueryString = value; + } +} internal class MutableRequestEventLayer: IRoutingLayer { public MutableRequestEventLayer(string name, List>> handlers) diff --git a/src/Imazen.Routing/Promises/Pipelines/ImagingMiddleware.cs b/src/Imazen.Routing/Promises/Pipelines/ImagingMiddleware.cs index 2f1c1a5f..fce5561b 100644 --- a/src/Imazen.Routing/Promises/Pipelines/ImagingMiddleware.cs +++ b/src/Imazen.Routing/Promises/Pipelines/ImagingMiddleware.cs @@ -6,7 +6,7 @@ using Imazen.Abstractions.HttpStrings; using Imazen.Abstractions.Logging; using Imazen.Abstractions.Resulting; -using Imazen.Routing.Compatibility.ImageflowServer; +using Imazen.Routing.Promises.Pipelines.Watermarking; using Imazen.Routing.Helpers; using Imazen.Routing.HttpAbstractions; using Imazen.Routing.Requests; diff --git a/src/Imazen.Routing/Compatibility/ImageflowServer/WatermarkWithPath.cs b/src/Imazen.Routing/Promises/Pipelines/Watermarking/WatermarkWithPath.cs similarity index 69% rename from src/Imazen.Routing/Compatibility/ImageflowServer/WatermarkWithPath.cs rename to src/Imazen.Routing/Promises/Pipelines/Watermarking/WatermarkWithPath.cs index 65c8c7c0..98295998 100644 --- a/src/Imazen.Routing/Compatibility/ImageflowServer/WatermarkWithPath.cs +++ b/src/Imazen.Routing/Promises/Pipelines/Watermarking/WatermarkWithPath.cs @@ -1,6 +1,6 @@ using Imageflow.Fluent; -namespace Imazen.Routing.Compatibility.ImageflowServer; +namespace Imazen.Routing.Promises.Pipelines.Watermarking; public interface IWatermark { @@ -9,11 +9,11 @@ public interface IWatermark WatermarkOptions Watermark { get; } } -public record class WatermarkWithPath(string? Name, string VirtualPath, WatermarkOptions Watermark) +public record WatermarkWithPath(string? Name, string VirtualPath, WatermarkOptions Watermark) : IWatermark { public static WatermarkWithPath FromIWatermark(IWatermark watermark) { return new WatermarkWithPath(watermark.Name, watermark.VirtualPath, watermark.Watermark); } -} +} diff --git a/src/Imazen.Routing/Promises/Pipelines/WatermarkingLogicOptions.cs b/src/Imazen.Routing/Promises/Pipelines/Watermarking/WatermarkingLogicOptions.cs similarity index 97% rename from src/Imazen.Routing/Promises/Pipelines/WatermarkingLogicOptions.cs rename to src/Imazen.Routing/Promises/Pipelines/Watermarking/WatermarkingLogicOptions.cs index 408bfcd4..fb64e93b 100644 --- a/src/Imazen.Routing/Promises/Pipelines/WatermarkingLogicOptions.cs +++ b/src/Imazen.Routing/Promises/Pipelines/Watermarking/WatermarkingLogicOptions.cs @@ -1,10 +1,12 @@ using System.Buffers; using Imageflow.Fluent; -using Imazen.Routing.Compatibility.ImageflowServer; using Imazen.Routing.HttpAbstractions; using Imazen.Routing.Requests; -namespace Imazen.Routing.Promises.Pipelines; +namespace Imazen.Routing.Promises.Pipelines.Watermarking; + + + public record WatermarkingLogicOptions(Func? LookupWatermark, Func?, IList?>? MutateWatermarks) { diff --git a/src/Imazen.Routing/Promises/hash_design.md b/src/Imazen.Routing/Promises/hash_design.md deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Imazen.Routing/Serving/ImageServer.cs b/src/Imazen.Routing/Serving/ImageServer.cs index 64e2d122..5481a912 100644 --- a/src/Imazen.Routing/Serving/ImageServer.cs +++ b/src/Imazen.Routing/Serving/ImageServer.cs @@ -12,6 +12,7 @@ using Imazen.Routing.HttpAbstractions; using Imazen.Routing.Promises; using Imazen.Routing.Promises.Pipelines; +using Imazen.Routing.Promises.Pipelines.Watermarking; using Imazen.Routing.Requests; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; diff --git a/tests/ImazenShared.Tests/Routing/Serving/ImageServerTests.cs b/tests/ImazenShared.Tests/Routing/Serving/ImageServerTests.cs index fa7057a7..84387204 100644 --- a/tests/ImazenShared.Tests/Routing/Serving/ImageServerTests.cs +++ b/tests/ImazenShared.Tests/Routing/Serving/ImageServerTests.cs @@ -1,6 +1,6 @@ using Imazen.Abstractions.DependencyInjection; using Imazen.Abstractions.Logging; -using Imazen.Routing.Compatibility.ImageflowServer; +using Imazen.Routing.Promises.Pipelines.Watermarking; using Imazen.Routing.Engine; using Imazen.Routing.HttpAbstractions; using Imazen.Routing.Layers;