Skip to content

Version 3.0.0 Breaking Changes

Cristi Pufu edited this page Feb 22, 2019 · 2 revisions

The changes are explained in more details in this pull request


  • The target framework has been updated to netstandard2.0.

  • We have to manually seed the appsettings.json policies:

public static async Task Main(string[] args)
{
    IWebHost webHost = CreateWebHostBuilder(args).Build();

    using (var scope = webHost.Services.CreateScope())
    {
         // get the ClientPolicyStore instance
         var clientPolicyStore = scope.ServiceProvider.GetRequiredService<IClientPolicyStore>();

         // seed Client data from appsettings
         await clientPolicyStore.SeedAsync();

         // get the IpPolicyStore instance
         var ipPolicyStore = scope.ServiceProvider.GetRequiredService<IIpPolicyStore>();

         // seed IP data from appsettings
         await ipPolicyStore.SeedAsync();
    }

    await webHost.RunAsync();
}
  • We have to register two new services in Startup.cs:
// https://github.com/aspnet/Hosting/issues/793
// the IHttpContextAccessor service is not registered by default.
// the clientId/clientIp resolvers use it.
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

// configure the resolvers
services.AddSingleton<IRateLimitConfiguration, RateLimitConfiguration>();
Clone this wiki locally