diff --git a/gateways/web/src/EShopOnAbp.WebGateway/ReverseProxyBuilderExtensions.cs b/gateways/web/src/EShopOnAbp.WebGateway/ReverseProxyBuilderExtensions.cs index 70be5da1..3dd29485 100644 --- a/gateways/web/src/EShopOnAbp.WebGateway/ReverseProxyBuilderExtensions.cs +++ b/gateways/web/src/EShopOnAbp.WebGateway/ReverseProxyBuilderExtensions.cs @@ -1,14 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text.Json; using EShopOnAbp.WebGateway.Aggregations.ApplicationConfiguration; using EShopOnAbp.WebGateway.Aggregations.Localization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Json; using Yarp.ReverseProxy.Configuration; namespace EShopOnAbp.WebGateway; @@ -22,36 +20,35 @@ public static class ReverseProxyBuilderExtensions proxyBuilder.Use(async (context, next) => { var endpoint = context.GetEndpoint(); - + var localizationAggregation = context.RequestServices .GetRequiredService(); - + var appConfigurationAggregation = context.RequestServices .GetRequiredService(); - var jsonSerializer = context.RequestServices.GetRequiredService(); - // The "/api/abp/application-localization" endpoint if (localizationAggregation.LocalizationRouteName == endpoint?.DisplayName) { var localizationRequestInput = CreateLocalizationRequestInput(context, localizationAggregation.LocalizationEndpoint); - + var result = await localizationAggregation.GetLocalizationAsync(localizationRequestInput); - await context.Response.WriteAsync(jsonSerializer.Serialize(result)); + await context.Response.WriteAsJsonAsync(result); + return; + } + + // The "/api/abp/application-configuration" endpoint + if (appConfigurationAggregation.AppConfigRouteName == endpoint?.DisplayName) + { + var appConfigurationRequestInput = + CreateAppConfigurationRequestInput(context, appConfigurationAggregation.AppConfigEndpoint); + + var result = + await appConfigurationAggregation.GetAppConfigurationAsync(appConfigurationRequestInput); + await context.Response.WriteAsJsonAsync(result); return; } - - // // The "/api/abp/application-configuration" endpoint - // if (appConfigurationAggregation.AppConfigRouteName == endpoint?.DisplayName) - // { - // var appConfigurationRequestInput = - // CreateAppConfigurationRequestInput(context, appConfigurationAggregation.AppConfigEndpoint); - // - // var result = await appConfigurationAggregation.GetAppConfigurationAsync(appConfigurationRequestInput); - // await context.Response.WriteAsync(jsonSerializer.Serialize(result)); - // return; - // } await next(); }); @@ -67,7 +64,7 @@ public static class ReverseProxyBuilderExtensions var input = new AppConfigurationRequest(); string path = $"{appConfigurationPath}?includeLocalizationResources=false"; - + var clusterList = GetClusters(proxyConfig); foreach (var cluster in clusterList) { diff --git a/tye.yaml b/tye.yaml index 31a931d7..ff389ce8 100644 --- a/tye.yaml +++ b/tye.yaml @@ -67,14 +67,14 @@ services: env_file: - ./.env -# - name: web-gateway -# project: gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj -# bindings: -# - protocol: https -# port: 44372 -# env: -# - Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx -# - Kestrel__Certificates__Default__Password=8b6039b6-c67a-448b-977b-0ce6d3fcfd49 +- name: web-gateway + project: gateways/web/src/EShopOnAbp.WebGateway/EShopOnAbp.WebGateway.csproj + bindings: + - protocol: https + port: 44372 + env: + - Kestrel__Certificates__Default__Path=../../../../etc/dev-cert/localhost.pfx + - Kestrel__Certificates__Default__Password=8b6039b6-c67a-448b-977b-0ce6d3fcfd49 - name: web-public-gateway project: gateways/web-public/src/EShopOnAbp.WebPublicGateway/EShopOnAbp.WebPublicGateway.csproj