Skip to content

Commit ba5b20e

Browse files
committed
Add ImageflowMiddlewareOptions.SetLicenseKey() and .SetMyOpenSourceProjectUrl()
1 parent 6441025 commit ba5b20e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Diff for: src/Imageflow.Server/EnforceLicenseWith.cs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Imageflow.Server
2+
{
3+
public enum EnforceLicenseWith
4+
{
5+
RedDotWatermark,
6+
Http422Error
7+
}
8+
}

Diff for: src/Imageflow.Server/ImageflowMiddlewareOptions.cs

+35
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public class ImageflowMiddlewareOptions
1212
public ImageflowMiddlewareOptions()
1313
{
1414
}
15+
16+
internal string LicenseKey { get; set; }
17+
internal EnforceLicenseWith EnforcementMethod { get; set; }
18+
19+
public string MyOpenSourceProjectUrl { get; set; }
1520

1621
public bool AllowMemoryCaching { get; set; } = false;
1722

@@ -80,6 +85,36 @@ public ImageflowMiddlewareOptions HandleExtensionlessRequestsUnder(string prefix
8085
ExtensionlessPaths.Add(new ExtensionlessPath() { Prefix = prefix, PrefixComparison = prefixComparison});
8186
return this;
8287
}
88+
89+
/// <summary>
90+
/// Use this if you are complying with the AGPL v3 and open-sourcing your project.
91+
/// Provide the URL to your version control system or source code download page.
92+
/// Use .SetLicenseKey() instead if you are not open-sourcing your project.
93+
/// </summary>
94+
/// <param name="myOpenSourceProjectUrl">Provide the URL to your version control
95+
/// system or source code download page.</param>
96+
/// <returns></returns>
97+
public ImageflowMiddlewareOptions SetMyOpenSourceProjectUrl(string myOpenSourceProjectUrl)
98+
{
99+
MyOpenSourceProjectUrl = myOpenSourceProjectUrl;
100+
return this;
101+
}
102+
103+
/// <summary>
104+
/// If you do not call this, Imageflow.Server will watermark image requests with a red dot.
105+
///
106+
/// If you are open-sourcing your project and complying with the AGPL v3, you can call
107+
/// .SetMyOpenSourceProjectUrl() instead.
108+
/// </summary>
109+
/// <param name="licenseKey"></param>
110+
/// <param name="enforcementMethod"></param>
111+
/// <returns></returns>
112+
public ImageflowMiddlewareOptions SetLicenseKey(EnforceLicenseWith enforcementMethod, string licenseKey)
113+
{
114+
EnforcementMethod = enforcementMethod;
115+
LicenseKey = licenseKey;
116+
return this;
117+
}
83118

84119
public ImageflowMiddlewareOptions SetRequestSignatureOptions(RequestSignatureOptions options)
85120
{

0 commit comments

Comments
 (0)