|
|
|
@ -1,12 +1,11 @@ |
|
|
|
using System; |
|
|
|
using EShopOnAbp.BasketService.Configs; |
|
|
|
using EShopOnAbp.BasketService.Grpc; |
|
|
|
using System.Collections.Generic; |
|
|
|
using EShopOnAbp.CatalogService; |
|
|
|
using EShopOnAbp.CatalogService.Grpc; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp.Application; |
|
|
|
using Volo.Abp.AutoMapper; |
|
|
|
using Volo.Abp.Http.Client; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
|
|
|
|
namespace EShopOnAbp.BasketService |
|
|
|
@ -23,19 +22,19 @@ namespace EShopOnAbp.BasketService |
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
var configuration = context.Services.GetConfiguration(); |
|
|
|
context.Services.AddOptions(); |
|
|
|
context.Services.Configure<UrlsConfig>(configuration.GetSection("urls")); |
|
|
|
|
|
|
|
Configure<AbpAutoMapperOptions>(options => |
|
|
|
{ |
|
|
|
options.AddMaps<BasketServiceApplicationModule>(); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
context.Services.AddGrpcClient<ProductPublic.ProductPublicClient>((services, options) => |
|
|
|
{ |
|
|
|
var catalogApi = services.GetRequiredService<IOptions<UrlsConfig>>().Value.GrpcCatalog; |
|
|
|
options.Address = new Uri(catalogApi); |
|
|
|
}).AddInterceptor<GrpcExceptionInterceptor>(); |
|
|
|
var remoteServiceConfigurationProvider = services.GetRequiredService<IRemoteServiceConfigurationProvider>(); |
|
|
|
var catalogServiceConfiguration = remoteServiceConfigurationProvider.GetConfigurationOrDefaultAsync("Catalog").Result; |
|
|
|
var catalogGrpcUrl = catalogServiceConfiguration.GetOrDefault("GrpcUrl"); |
|
|
|
|
|
|
|
options.Address = new Uri(catalogGrpcUrl); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|