public static IServiceCollection ConfigureHttpServices(this IServiceCollection services) { services.AddTransient <LiGetCompatibilityOptions, LiGetCompatibilityOptions>(provider => provider .GetRequiredService <IOptions <BaGetOptions> >() .Value .LiGetCompat ); services.AddSingleton <IEdmModel>(provider => { var odataModelBuilder = new NuGetWebApiODataModelBuilder(); odataModelBuilder.Build(); return(odataModelBuilder.Model); }); services.AddTransient <IODataPackageSerializer, ODataPackageSerializer>(); AddCarter(services); services.AddCors(); services.AddSingleton <IConfigureOptions <CorsOptions>, ConfigureCorsOptions>(); services.Configure <ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; // Do not restrict to local network/proxy options.KnownNetworks.Clear(); options.KnownProxies.Clear(); }); return(services); }
protected override PackagesODataController CreateController() { repo = new Mock <IMirroringPackageRepository>(); var builder = new NuGetWebApiODataModelBuilder(); builder.Build(); model = builder.Model; return(new PackagesODataController { Repository = repo.Object }); }