Browse Source

Updated basket for service proxy

pull/79/head
Galip Tolga Erdem 5 years ago
parent
commit
bfc6789980
  1. 6
      services/basket/src/EShopOnAbp.BasketService.Contracts/BasketServiceConstants.cs
  2. 20
      services/basket/src/EShopOnAbp.BasketService.Contracts/BasketServiceContractsModule.cs
  3. 2
      services/basket/src/EShopOnAbp.BasketService.Contracts/EShopOnAbp.BasketService.Contracts.csproj
  4. 28
      services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs
  5. 4
      services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj

6
services/basket/src/EShopOnAbp.BasketService.Contracts/BasketServiceConstants.cs

@ -0,0 +1,6 @@
namespace EShopOnAbp.BasketService;
public static class BasketServiceConstants
{
public static readonly string RemoteServiceName = "Basket";
}

20
services/basket/src/EShopOnAbp.BasketService.Contracts/BasketServiceContractsModule.cs

@ -1,22 +1,26 @@
using EShopOnAbp.BasketService.Localization;
using Microsoft.Extensions.DependencyInjection;
using EShopOnAbp.CatalogService;
using Volo.Abp.Application;
using Volo.Abp.Authorization;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
namespace EShopOnAbp.BasketService;
public class BasketServiceContractsModule : AbpModule
[DependsOn(
typeof(CatalogServiceApplicationContractsModule),
typeof(AbpDddApplicationContractsModule),
typeof(AbpAuthorizationModule),
typeof(AbpValidationModule)
)]
public class BasketServiceContractsModule : AbpModule
{
public const string RemoteServiceName = "Catalog";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddStaticHttpClientProxies(
typeof(BasketServiceContractsModule).Assembly,
RemoteServiceName
);
Configure<AbpLocalizationOptions>(options =>
{
options.Resources

2
services/basket/src/EShopOnAbp.BasketService.Contracts/EShopOnAbp.BasketService.Contracts.csproj

@ -8,9 +8,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Http.Client" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Authorization" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Validation" Version="5.1.2" />
</ItemGroup>
<ItemGroup>

28
services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs

@ -1,5 +1,4 @@
using EShopOnAbp.BasketService.Entities;
using EShopOnAbp.BasketService.Localization;
using EShopOnAbp.CatalogService.Grpc;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using EShopOnAbp.Shared.Hosting.Microservices;
@ -10,27 +9,22 @@ using Volo.Abp;
using Volo.Abp.Application;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.Authorization;
using Volo.Abp.AutoMapper;
using Volo.Abp.Caching;
using Volo.Abp.Domain;
using Volo.Abp.Http.Client;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;
namespace EShopOnAbp.BasketService
{
[DependsOn(typeof(AbpAuthorizationModule),
[DependsOn(
typeof(AbpAspNetCoreMvcModule),
typeof(AbpHttpClientModule),
typeof(AbpAutoMapperModule),
typeof(AbpCachingModule),
typeof(AbpDddApplicationModule),
typeof(AbpDddDomainModule),
typeof(AbpValidationModule),
typeof(BasketServiceContractsModule),
typeof(EShopOnAbpSharedHostingMicroservicesModule)
)]
@ -39,9 +33,13 @@ namespace EShopOnAbp.BasketService
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = hostingEnvironment.IsDevelopment();
var configuration = context.Services.GetConfiguration();
ConfigureAutoMapper();
ConfigureAspNetCoreRouting(context);
ConfigureGrpc(context);
ConfigureDistributedCache();
ConfigureVirtualFileSystem();
@ -49,7 +47,19 @@ namespace EShopOnAbp.BasketService
ConfigureSwagger(context, configuration);
ConfigureAutoApiControllers();
}
private void ConfigureAspNetCoreRouting(ServiceConfigurationContext context)
{
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(BasketServiceModule).Assembly, opts =>
{
opts.RootPath = "basket";
opts.RemoteServiceName = BasketServiceConstants.RemoteServiceName;
});
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();

4
services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj

@ -14,14 +14,12 @@
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.0" />
<PackageReference Include="Volo.Abp.Http.Client" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Authorization" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Http.Client" Version="5.1.2" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="5.1.2" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Caching" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="5.1.2" />
<PackageReference Include="Volo.Abp.Validation" Version="5.1.2" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save