Ends in:
3 DAYS
5 HRS
7 MIN
30 SEC
Ends in:
3 D
5 H
7 M
30 S
Open Closed

Gateway yarp environment #7140


User avatar
0
mmaldonado@emscltd.com created

Just as recomendation to improve Abp.io

  • ABP Framework version: 8.1.1
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

I am facing problems when publishing gateways to different environments, because I have:

  • yarp.json for local environment or development
  • yarp.Stage.json for Stage or QA
  • yarp.Production.json for Production
using Microsoft.Extensions.Configuration;

namespace Microsoft.Extensions.Hosting;

public static class AbpHostingHostBuilderExtensions
{
    public const string AppYarpJsonPath = "yarp.json";

    public static IHostBuilder AddYarpJson(
        this IHostBuilder hostBuilder,
        bool optional = true,
        bool reloadOnChange = true,
        string path = AppYarpJsonPath)
    {
        return hostBuilder.ConfigureAppConfiguration((_, builder) =>
        {
            builder.AddJsonFile(
                path: AppYarpJsonPath, // should be path
                optional: optional,
                reloadOnChange: reloadOnChange
            );
        });
    }
}

so I could use from program.cs on gateway .AddYarpJson(path: $"yarp.{builder.Environment.EnvironmentName}.json")

but even better should be

public static IHostBuilder AddYarpJson(
    this IHostBuilder hostBuilder,
    bool optional = true,
    bool reloadOnChange = true,
    string path = AppYarpJsonPath)
{
    return hostBuilder.ConfigureAppConfiguration((context, builder) =>
    {
        builder.AddJsonFile(
            path: path,
            optional: optional,
            reloadOnChange: reloadOnChange
        );

        builder.AddJsonFile(
            path: $"yarp.{context.HostingEnvironment.EnvironmentName}.json",
            optional: optional,
            reloadOnChange: reloadOnChange
        );
    });
}

1 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Thanks for your suggestion, we will improve the template

Made with ❤️ on ABP v9.1.0-preview. Updated on December 02, 2024, 12:35