// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(); services.AddHealthChecks(); services.AddCors(options => { options.AddPolicy("AllowAll", builder => { builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); var apiEncryptionServiceSettings = new ApiEncryptionServiceSettings(); Configuration.Bind(nameof(apiEncryptionServiceSettings), apiEncryptionServiceSettings); services.AddSingleton(apiEncryptionServiceSettings); services.AddScoped <IEncryptionService, EncryptionService>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddHostedService <KeyRotationHostedService>(); services.AddHttpClient(); services.AddHttpClient <IApiClient, ApiClient>(); }
public ApiClient(HttpClient client, ApiEncryptionServiceSettings apiEncryptionServiceSettings) { client.BaseAddress = new Uri(apiEncryptionServiceSettings.Host); client.DefaultRequestHeaders.Add("Accept", "application/json"); Client = client; }