diff --git a/Program.cs b/Program.cs
index 46d6380..b70cb4b 100644
--- a/Program.cs
+++ b/Program.cs
@@ -2,9 +2,33 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OpenAI.Chat;
+using ThrottlingTroll;
var host = new HostBuilder()
- .ConfigureFunctionsWebApplication()
+ .ConfigureFunctionsWebApplication((builderContext, workerAppBuilder) => {
+ workerAppBuilder.UseThrottlingTroll(options => {
+ options.Config = new ThrottlingTrollConfig
+ {
+ Rules =
+ [
+ new ThrottlingTrollRule
+ {
+ UriPattern = "/api/Iterator_Start",
+ LimitMethod = new FixedWindowRateLimitMethod
+ {
+ PermitLimit = 10,
+ IntervalInSeconds = 3600,
+ }
+ }
+ ]
+ };
+ options.IdentityIdExtractor = request =>
+ {
+ var httpRequest = ((IIncomingHttpRequestProxy)request).Request;
+ return httpRequest.HttpContext.Connection.RemoteIpAddress?.ToString();
+ };
+ });
+ })
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
diff --git a/WhiteCrow.csproj b/WhiteCrow.csproj
index ce6863e..09b2e78 100644
--- a/WhiteCrow.csproj
+++ b/WhiteCrow.csproj
@@ -16,6 +16,7 @@
+