Skip to content

Commit

Permalink
WIP - cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Jan 27, 2024
1 parent dfda9ff commit 31fc0dc
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Imageflow.Server/LegacyOptions/NamedWatermark.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Imageflow.Fluent;
using Imazen.Routing.Compatibility.ImageflowServer;
using Imazen.Routing.Promises.Pipelines.Watermarking;
using Newtonsoft.Json;

namespace Imageflow.Server
Expand Down
32 changes: 0 additions & 32 deletions src/Imageflow.Server/UpdatedUrlEventArgs.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions src/Imazen.Routing/Imazen.Routing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@

<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.*" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
</ItemGroup>

<ItemGroup>
<Folder Include="Compatibility\ImageflowServer\Internal\" />
</ItemGroup>
</Project>
8 changes: 7 additions & 1 deletion src/Imazen.Routing/Layers/LicensingLayer.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
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;
using Imazen.Routing.Serving;

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";
Expand Down
21 changes: 20 additions & 1 deletion src/Imazen.Routing/Layers/MutableRequestEventLayer.cs
Original file line number Diff line number Diff line change
@@ -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<T>
Expand All @@ -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<string,StringValues> Query {
get => Request.MutableQueryString;
set => Request.MutableQueryString = value;
}
}
internal class MutableRequestEventLayer: IRoutingLayer
{
public MutableRequestEventLayer(string name, List<PathPrefixHandler<Func<MutableRequestEventArgs, bool>>> handlers)
Expand Down
2 changes: 1 addition & 1 deletion src/Imazen.Routing/Promises/Pipelines/ImagingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Imageflow.Fluent;

namespace Imazen.Routing.Compatibility.ImageflowServer;
namespace Imazen.Routing.Promises.Pipelines.Watermarking;

public interface IWatermark
{
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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<string, WatermarkWithPath?>? LookupWatermark, Func<IRequestSnapshot, IList<WatermarkWithPath>?, IList<WatermarkWithPath>?>? MutateWatermarks)
{
Expand Down
Empty file.
1 change: 1 addition & 0 deletions src/Imazen.Routing/Serving/ImageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 31fc0dc

Please sign in to comment.