ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.35k stars 1.63k forks source link

Map response of rate limit quota into exception #2035

Closed sarahhachouche1 closed 5 months ago

sarahhachouche1 commented 5 months ago

I want to map response of rate limit quota into exception,

`app.UseSwaggerForOcelotUI(opt => { var serverOcelot = Configuration["ServerOcelot"]; // Could be replaced by a non existing functionality https://github.com/dotnet/aspnetcore/issues/5898 opt.PathToSwaggerGenerator = "/swagger/docs"; opt.DownstreamSwaggerEndPointBasePath = $"{serverOcelot}/swagger/docs"; opt.ReConfigureUpstreamSwaggerJson = AlterUpsteamSwaggeerJson; opt.ServerOcelot = $"{serverOcelot}"; }) .UseOcelot() .Wait();

app.Use(async (context, next) => { await next(context);

if (context.Response.StatusCode == 429)
{
    throw new RateLimitException("Rate limit exceed");
}

});` but its not even reaching my startup.cs any insight how to do so