Browse Source

Removed custom urls and added GrpcUrl to Catalog remote service

pull/75/head
Galip Tolga Erdem 5 years ago
parent
commit
9c7ad7411a
  1. 19
      services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs
  2. 7
      services/basket/src/EShopOnAbp.BasketService.Application/Configs/UrlsConfig.cs
  3. 4
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.Development.json
  4. 3
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json

19
services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs

@ -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);
});
}
}
}

7
services/basket/src/EShopOnAbp.BasketService.Application/Configs/UrlsConfig.cs

@ -1,7 +0,0 @@
namespace EShopOnAbp.BasketService.Configs;
public class UrlsConfig
{
public string Catalog { get; set; }
public string GrpcCatalog { get; set; }
}

4
services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.Development.json

@ -1,6 +1,2 @@
{
"urls": {
"catalog": "https://localhost:44354",
"grpcCatalog": "http://localhost:81"
}
}

3
services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json

@ -11,7 +11,8 @@
},
"RemoteServices": {
"Catalog": {
"BaseUrl": "https://localhost:44354/"
"BaseUrl": "https://localhost:44354/",
"GrpcUrl": "http://localhost:81"
}
},
"Logging": {

Loading…
Cancel
Save