From a616aa83602afc2d9ad9dd61fec69e1c09f3ba47 Mon Sep 17 00:00:00 2001 From: Joe Whiteaker <47674962+josephaw1022@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:57:09 -0500 Subject: [PATCH 1/2] progress in yarp example --- Directory.Packages.props | 7 +- .../AspireWithYarp.AppHost.csproj | 24 ++++ .../AspireWithYarp.AppHost/Program.cs | 27 ++++ .../Properties/launchSettings.json | 16 +++ .../appsettings.Development.json | 8 ++ .../AspireWithYarp.AppHost/appsettings.json | 9 ++ .../AspireWithYarp.ServiceDefaults.csproj | 24 ++++ .../Extensions.cs | 119 ++++++++++++++++++ samples/AspireWithYarp/AspireWithYarp.sln | 66 ++++++++++ .../BlazorPublicSiteBetaVersion.csproj | 13 ++ .../Components/App.razor | 18 +++ .../Components/Layout/MainLayout.razor | 9 ++ .../Components/Layout/MainLayout.razor.css | 18 +++ .../Components/Pages/Error.razor | 36 ++++++ .../Components/Pages/Home.razor | 7 ++ .../Components/Routes.razor | 6 + .../Components/_Imports.razor | 10 ++ .../BlazorPublicSiteBetaVersion/Program.cs | 27 ++++ .../Properties/launchSettings.json | 29 +++++ .../appsettings.Development.json | 8 ++ .../appsettings.json | 9 ++ .../wwwroot/app.css | 29 +++++ .../FeedMicroservice/FeedMicroservice.csproj | 19 +++ .../FeedMicroservice/FeedMicroservice.http | 6 + .../FeedMicroservice/Program.cs | 31 +++++ .../Properties/launchSettings.json | 41 ++++++ .../appsettings.Development.json | 8 ++ .../FeedMicroservice/appsettings.json | 9 ++ .../ProfileMicroservice.csproj | 19 +++ .../ProfileMicroservice.http | 6 + .../ProfileMicroservice/Program.cs | 30 +++++ .../Properties/launchSettings.json | 31 +++++ .../appsettings.Development.json | 8 ++ .../ProfileMicroservice/appsettings.json | 9 ++ .../BlazorPublicSiteBetaVersion.csproj | 13 ++ .../Components/App.razor | 18 +++ .../Components/Layout/MainLayout.razor | 9 ++ .../Components/Layout/MainLayout.razor.css | 18 +++ .../Components/Pages/Error.razor | 36 ++++++ .../Components/Pages/Home.razor | 7 ++ .../Components/Routes.razor | 6 + .../Components/_Imports.razor | 10 ++ .../PublicSiteBetaVersion/Program.cs | 38 ++++++ .../Properties/launchSettings.json | 38 ++++++ .../appsettings.Development.json | 8 ++ .../PublicSiteBetaVersion/appsettings.json | 9 ++ .../PublicSiteBetaVersion/wwwroot/app.css | 29 +++++ .../AspireWithYarp/YarpApiGateway/Program.cs | 15 +++ .../Properties/launchSettings.json | 41 ++++++ .../YarpApiGateway/YarpApiGateway.csproj | 19 +++ .../YarpApiGateway/YarpApiGateway.http | 6 + .../appsettings.Development.json | 8 ++ .../YarpApiGateway/appsettings.json | 53 ++++++++ samples/AspireWithYarp/YarpIngress/Program.cs | 15 +++ .../Properties/launchSettings.json | 31 +++++ .../YarpIngress/YarpIngress.csproj | 19 +++ .../YarpIngress/YarpIngress.http | 6 + .../YarpIngress/appsettings.Development.json | 8 ++ .../YarpIngress/appsettings.json | 48 +++++++ .../BlazorPublicSite.csproj | 15 +++ .../blazor-public-site/Components/App.razor | 18 +++ .../Components/Layout/MainLayout.razor | 9 ++ .../Components/Layout/MainLayout.razor.css | 18 +++ .../Components/Pages/Error.razor | 36 ++++++ .../Components/Pages/Home.razor | 28 +++++ .../Components/Routes.razor | 6 + .../Components/_Imports.razor | 11 ++ .../blazor-public-site/Program.cs | 37 ++++++ .../Properties/launchSettings.json | 29 +++++ .../Services/FeedService.cs | 10 ++ .../appsettings.Development.json | 8 ++ .../blazor-public-site/appsettings.json | 9 ++ .../blazor-public-site/wwwroot/app.css | 29 +++++ 73 files changed, 1506 insertions(+), 1 deletion(-) create mode 100644 samples/AspireWithYarp/AspireWithYarp.AppHost/AspireWithYarp.AppHost.csproj create mode 100644 samples/AspireWithYarp/AspireWithYarp.AppHost/Program.cs create mode 100644 samples/AspireWithYarp/AspireWithYarp.AppHost/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.Development.json create mode 100644 samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.json create mode 100644 samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/AspireWithYarp.ServiceDefaults.csproj create mode 100644 samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/Extensions.cs create mode 100644 samples/AspireWithYarp/AspireWithYarp.sln create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/App.razor create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor.css create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Error.razor create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Home.razor create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Routes.razor create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/_Imports.razor create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Program.cs create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.Development.json create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.json create mode 100644 samples/AspireWithYarp/BlazorPublicSiteBetaVersion/wwwroot/app.css create mode 100644 samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.csproj create mode 100644 samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.http create mode 100644 samples/AspireWithYarp/FeedMicroservice/Program.cs create mode 100644 samples/AspireWithYarp/FeedMicroservice/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/FeedMicroservice/appsettings.Development.json create mode 100644 samples/AspireWithYarp/FeedMicroservice/appsettings.json create mode 100644 samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.csproj create mode 100644 samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.http create mode 100644 samples/AspireWithYarp/ProfileMicroservice/Program.cs create mode 100644 samples/AspireWithYarp/ProfileMicroservice/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/ProfileMicroservice/appsettings.Development.json create mode 100644 samples/AspireWithYarp/ProfileMicroservice/appsettings.json create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Components/App.razor create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor.css create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Error.razor create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Home.razor create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Components/Routes.razor create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Components/_Imports.razor create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Program.cs create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.Development.json create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.json create mode 100644 samples/AspireWithYarp/PublicSiteBetaVersion/wwwroot/app.css create mode 100644 samples/AspireWithYarp/YarpApiGateway/Program.cs create mode 100644 samples/AspireWithYarp/YarpApiGateway/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.csproj create mode 100644 samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.http create mode 100644 samples/AspireWithYarp/YarpApiGateway/appsettings.Development.json create mode 100644 samples/AspireWithYarp/YarpApiGateway/appsettings.json create mode 100644 samples/AspireWithYarp/YarpIngress/Program.cs create mode 100644 samples/AspireWithYarp/YarpIngress/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/YarpIngress/YarpIngress.csproj create mode 100644 samples/AspireWithYarp/YarpIngress/YarpIngress.http create mode 100644 samples/AspireWithYarp/YarpIngress/appsettings.Development.json create mode 100644 samples/AspireWithYarp/YarpIngress/appsettings.json create mode 100644 samples/AspireWithYarp/blazor-public-site/BlazorPublicSite.csproj create mode 100644 samples/AspireWithYarp/blazor-public-site/Components/App.razor create mode 100644 samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor create mode 100644 samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor.css create mode 100644 samples/AspireWithYarp/blazor-public-site/Components/Pages/Error.razor create mode 100644 samples/AspireWithYarp/blazor-public-site/Components/Pages/Home.razor create mode 100644 samples/AspireWithYarp/blazor-public-site/Components/Routes.razor create mode 100644 samples/AspireWithYarp/blazor-public-site/Components/_Imports.razor create mode 100644 samples/AspireWithYarp/blazor-public-site/Program.cs create mode 100644 samples/AspireWithYarp/blazor-public-site/Properties/launchSettings.json create mode 100644 samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs create mode 100644 samples/AspireWithYarp/blazor-public-site/appsettings.Development.json create mode 100644 samples/AspireWithYarp/blazor-public-site/appsettings.json create mode 100644 samples/AspireWithYarp/blazor-public-site/wwwroot/app.css diff --git a/Directory.Packages.props b/Directory.Packages.props index 738301bf..2c0e97be 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -61,11 +61,16 @@ + + + + + + - \ No newline at end of file diff --git a/samples/AspireWithYarp/AspireWithYarp.AppHost/AspireWithYarp.AppHost.csproj b/samples/AspireWithYarp/AspireWithYarp.AppHost/AspireWithYarp.AppHost.csproj new file mode 100644 index 00000000..30d1d291 --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.AppHost/AspireWithYarp.AppHost.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + enable + enable + true + + + + + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/AspireWithYarp.AppHost/Program.cs b/samples/AspireWithYarp/AspireWithYarp.AppHost/Program.cs new file mode 100644 index 00000000..b4cdace7 --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.AppHost/Program.cs @@ -0,0 +1,27 @@ +var builder = DistributedApplication.CreateBuilder(args); + +// Define our microservices +var profile = builder.AddProject("profile"); +var feed = builder.AddProject("feed"); + +// Define our gateway +var apiGateway = builder.AddProject("apigateway") + .WithReference(profile) + .WithReference(feed); + +// Define our clients +var publicSite = builder.AddProject("publicsite") + .WithReference(apiGateway); + + +var publicSiteBetaVersion = builder.AddProject("publicsitebetaversion") + .WithReference(apiGateway); + + +// Define the ingress for the clients +builder.AddProject("ingress") + .WithReference(publicSite) + .WithReference(publicSiteBetaVersion); + + +builder.Build().Run(); diff --git a/samples/AspireWithYarp/AspireWithYarp.AppHost/Properties/launchSettings.json b/samples/AspireWithYarp/AspireWithYarp.AppHost/Properties/launchSettings.json new file mode 100644 index 00000000..a14ead8b --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.AppHost/Properties/launchSettings.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15206", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16020" + } + } + } +} diff --git a/samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.Development.json b/samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.json b/samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.json new file mode 100644 index 00000000..31c092aa --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/AspireWithYarp.ServiceDefaults.csproj b/samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/AspireWithYarp.ServiceDefaults.csproj new file mode 100644 index 00000000..3dd7aa94 --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/AspireWithYarp.ServiceDefaults.csproj @@ -0,0 +1,24 @@ + + + + Library + net8.0 + enable + enable + true + + + + + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/Extensions.cs b/samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/Extensions.cs new file mode 100644 index 00000000..c59308d5 --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.ServiceDefaults/Extensions.cs @@ -0,0 +1,119 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using Microsoft.Extensions.Logging; +using OpenTelemetry.Logs; +using OpenTelemetry.Metrics; +using OpenTelemetry.Trace; + +namespace Microsoft.Extensions.Hosting; + +public static class Extensions +{ + public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder) + { + builder.ConfigureOpenTelemetry(); + + builder.AddDefaultHealthChecks(); + + builder.Services.AddServiceDiscovery(); + + builder.Services.ConfigureHttpClientDefaults(http => + { + // Turn on resilience by default + http.AddStandardResilienceHandler(); + + // Turn on service discovery by default + http.UseServiceDiscovery(); + }); + + return builder; + } + + public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder) + { + builder.Logging.AddOpenTelemetry(logging => + { + logging.IncludeFormattedMessage = true; + logging.IncludeScopes = true; + }); + + builder.Services.AddOpenTelemetry() + .WithMetrics(metrics => + { + metrics.AddRuntimeInstrumentation() + .AddBuiltInMeters(); + }) + .WithTracing(tracing => + { + if (builder.Environment.IsDevelopment()) + { + // We want to view all traces in development + tracing.SetSampler(new AlwaysOnSampler()); + } + + tracing.AddAspNetCoreInstrumentation() + .AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation(); + }); + + builder.AddOpenTelemetryExporters(); + + return builder; + } + + private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder) + { + var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]); + + if (useOtlpExporter) + { + builder.Services.Configure(logging => logging.AddOtlpExporter()); + builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter()); + builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter()); + } + + // Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) + // builder.Services.AddOpenTelemetry() + // .WithMetrics(metrics => metrics.AddPrometheusExporter()); + + // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.Exporter package) + // builder.Services.AddOpenTelemetry() + // .UseAzureMonitor(); + + return builder; + } + + public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder) + { + builder.Services.AddHealthChecks() + // Add a default liveness check to ensure app is responsive + .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); + + return builder; + } + + public static WebApplication MapDefaultEndpoints(this WebApplication app) + { + // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) + // app.MapPrometheusScrapingEndpoint(); + + // All health checks must pass for app to be considered ready to accept traffic after starting + app.MapHealthChecks("/health"); + + // Only health checks tagged with the "live" tag must pass for app to be considered alive + app.MapHealthChecks("/alive", new HealthCheckOptions + { + Predicate = r => r.Tags.Contains("live") + }); + + return app; + } + + private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) => + meterProviderBuilder.AddMeter( + "Microsoft.AspNetCore.Hosting", + "Microsoft.AspNetCore.Server.Kestrel", + "System.Net.Http"); +} diff --git a/samples/AspireWithYarp/AspireWithYarp.sln b/samples/AspireWithYarp/AspireWithYarp.sln new file mode 100644 index 00000000..f485f1c3 --- /dev/null +++ b/samples/AspireWithYarp/AspireWithYarp.sln @@ -0,0 +1,66 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34407.89 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspireWithYarp.AppHost", "AspireWithYarp.AppHost\AspireWithYarp.AppHost.csproj", "{716746FB-88DD-4518-854D-FF387312FF3F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspireWithYarp.ServiceDefaults", "AspireWithYarp.ServiceDefaults\AspireWithYarp.ServiceDefaults.csproj", "{5F4EF88F-37FF-4875-927C-98E3AE2072DF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorPublicSite", "blazor-public-site\BlazorPublicSite.csproj", "{7428EB8B-EBC5-439B-BEC8-635C98CB9613}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorPublicSiteBetaVersion", "BlazorPublicSiteBetaVersion\BlazorPublicSiteBetaVersion.csproj", "{8A3163A8-93A6-41CF-9E7C-68E8EACCB44E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YarpIngress", "YarpIngress\YarpIngress.csproj", "{95E2BD06-3E5D-4963-8064-BBB70D686028}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProfileMicroservice", "ProfileMicroservice\ProfileMicroservice.csproj", "{E337A639-3BEE-4787-8030-A46F034736CB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FeedMicroservice", "FeedMicroservice\FeedMicroservice.csproj", "{538CD43C-4D7D-495A-8A07-FC7443E234C0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YarpApiGateway", "YarpApiGateway\YarpApiGateway.csproj", "{250F2952-E052-4388-B643-DAD5C32224A6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {716746FB-88DD-4518-854D-FF387312FF3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {716746FB-88DD-4518-854D-FF387312FF3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {716746FB-88DD-4518-854D-FF387312FF3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {716746FB-88DD-4518-854D-FF387312FF3F}.Release|Any CPU.Build.0 = Release|Any CPU + {5F4EF88F-37FF-4875-927C-98E3AE2072DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F4EF88F-37FF-4875-927C-98E3AE2072DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F4EF88F-37FF-4875-927C-98E3AE2072DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F4EF88F-37FF-4875-927C-98E3AE2072DF}.Release|Any CPU.Build.0 = Release|Any CPU + {7428EB8B-EBC5-439B-BEC8-635C98CB9613}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7428EB8B-EBC5-439B-BEC8-635C98CB9613}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7428EB8B-EBC5-439B-BEC8-635C98CB9613}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7428EB8B-EBC5-439B-BEC8-635C98CB9613}.Release|Any CPU.Build.0 = Release|Any CPU + {8A3163A8-93A6-41CF-9E7C-68E8EACCB44E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A3163A8-93A6-41CF-9E7C-68E8EACCB44E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A3163A8-93A6-41CF-9E7C-68E8EACCB44E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A3163A8-93A6-41CF-9E7C-68E8EACCB44E}.Release|Any CPU.Build.0 = Release|Any CPU + {95E2BD06-3E5D-4963-8064-BBB70D686028}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95E2BD06-3E5D-4963-8064-BBB70D686028}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95E2BD06-3E5D-4963-8064-BBB70D686028}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95E2BD06-3E5D-4963-8064-BBB70D686028}.Release|Any CPU.Build.0 = Release|Any CPU + {E337A639-3BEE-4787-8030-A46F034736CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E337A639-3BEE-4787-8030-A46F034736CB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E337A639-3BEE-4787-8030-A46F034736CB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E337A639-3BEE-4787-8030-A46F034736CB}.Release|Any CPU.Build.0 = Release|Any CPU + {538CD43C-4D7D-495A-8A07-FC7443E234C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {538CD43C-4D7D-495A-8A07-FC7443E234C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {538CD43C-4D7D-495A-8A07-FC7443E234C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {538CD43C-4D7D-495A-8A07-FC7443E234C0}.Release|Any CPU.Build.0 = Release|Any CPU + {250F2952-E052-4388-B643-DAD5C32224A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {250F2952-E052-4388-B643-DAD5C32224A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {250F2952-E052-4388-B643-DAD5C32224A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {250F2952-E052-4388-B643-DAD5C32224A6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7D2D8671-2303-40E4-81A7-AF9585513E45} + EndGlobalSection +EndGlobal diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj new file mode 100644 index 00000000..d4b07626 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/App.razor b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/App.razor new file mode 100644 index 00000000..82d8b245 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/App.razor @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor new file mode 100644 index 00000000..9d5318ff --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor @@ -0,0 +1,9 @@ +@inherits LayoutComponentBase + +@Body + +@*
+ An unhandled error has occurred. + Reload + 🗙 +
*@ diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor.css b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor.css new file mode 100644 index 00000000..df8c10ff --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Layout/MainLayout.razor.css @@ -0,0 +1,18 @@ +#blazor-error-ui { + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + + #blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; + } diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Error.razor b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Error.razor new file mode 100644 index 00000000..576cc2d2 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Error.razor @@ -0,0 +1,36 @@ +@page "/Error" +@using System.Diagnostics + +Error + +

Error.

+

An error occurred while processing your request.

+ +@if (ShowRequestId) +{ +

+ Request ID: @RequestId +

+} + +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+ +@code{ + [CascadingParameter] + private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Home.razor b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Home.razor new file mode 100644 index 00000000..e2e9e7bf --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Pages/Home.razor @@ -0,0 +1,7 @@ +@page "/" + +Home + +

Welcome To the Beta Site 😎

+ +Welcome to the beta version of the public site. \ No newline at end of file diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Routes.razor b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Routes.razor new file mode 100644 index 00000000..d0df7816 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/Routes.razor @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/_Imports.razor b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/_Imports.razor new file mode 100644 index 00000000..25cfef76 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Components/_Imports.razor @@ -0,0 +1,10 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using BlazorPublicSiteBetaVersion +@using BlazorPublicSiteBetaVersion.Components diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Program.cs b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Program.cs new file mode 100644 index 00000000..6d5c0b87 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Program.cs @@ -0,0 +1,27 @@ +using BlazorPublicSiteBetaVersion.Components; + +var builder = WebApplication.CreateBuilder(args); + +builder.AddServiceDefaults(); + +// Add services to the container. +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +var app = builder.Build(); + +app.MapDefaultEndpoints(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); +} + +app.UseStaticFiles(); +app.UseAntiforgery(); + +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + +app.Run(); diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Properties/launchSettings.json b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Properties/launchSettings.json new file mode 100644 index 00000000..c92eab95 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:40066", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5058", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } + } diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.Development.json b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.json b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/wwwroot/app.css b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/wwwroot/app.css new file mode 100644 index 00000000..e398853b --- /dev/null +++ b/samples/AspireWithYarp/BlazorPublicSiteBetaVersion/wwwroot/app.css @@ -0,0 +1,29 @@ +h1:focus { + outline: none; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid #e50000; +} + +.validation-message { + color: #e50000; +} + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + + .blazor-error-boundary::after { + content: "An error has occurred." + } + +.darker-border-checkbox.form-check-input { + border-color: #929292; +} diff --git a/samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.csproj b/samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.csproj new file mode 100644 index 00000000..92a7e4ce --- /dev/null +++ b/samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.http b/samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.http new file mode 100644 index 00000000..38698aa8 --- /dev/null +++ b/samples/AspireWithYarp/FeedMicroservice/FeedMicroservice.http @@ -0,0 +1,6 @@ +@FeedMicroservice_HostAddress = http://localhost:5196 + +GET {{FeedMicroservice_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/samples/AspireWithYarp/FeedMicroservice/Program.cs b/samples/AspireWithYarp/FeedMicroservice/Program.cs new file mode 100644 index 00000000..3f758652 --- /dev/null +++ b/samples/AspireWithYarp/FeedMicroservice/Program.cs @@ -0,0 +1,31 @@ +var builder = WebApplication.CreateBuilder(args); + +builder.AddServiceDefaults(); + +// Add services to the container. +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +app.MapDefaultEndpoints(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + + +app.MapGet("/", () => +{ + var feedMessage = "This is the feed message microservice"; + + return Results.Ok(feedMessage); +}) +.WithName("GetFeedPosts") +.WithOpenApi(); + +app.Run(); diff --git a/samples/AspireWithYarp/FeedMicroservice/Properties/launchSettings.json b/samples/AspireWithYarp/FeedMicroservice/Properties/launchSettings.json new file mode 100644 index 00000000..649456b3 --- /dev/null +++ b/samples/AspireWithYarp/FeedMicroservice/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:8718", + "sslPort": 44398 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5196", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7019;http://localhost:5196", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/samples/AspireWithYarp/FeedMicroservice/appsettings.Development.json b/samples/AspireWithYarp/FeedMicroservice/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/FeedMicroservice/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/FeedMicroservice/appsettings.json b/samples/AspireWithYarp/FeedMicroservice/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/samples/AspireWithYarp/FeedMicroservice/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.csproj b/samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.csproj new file mode 100644 index 00000000..8ff53ead --- /dev/null +++ b/samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.http b/samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.http new file mode 100644 index 00000000..e6cecc60 --- /dev/null +++ b/samples/AspireWithYarp/ProfileMicroservice/ProfileMicroservice.http @@ -0,0 +1,6 @@ +@ProfileMicroservice_HostAddress = http://localhost:5056 + +GET {{ProfileMicroservice_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/samples/AspireWithYarp/ProfileMicroservice/Program.cs b/samples/AspireWithYarp/ProfileMicroservice/Program.cs new file mode 100644 index 00000000..7fa79a2c --- /dev/null +++ b/samples/AspireWithYarp/ProfileMicroservice/Program.cs @@ -0,0 +1,30 @@ +var builder = WebApplication.CreateBuilder(args); + +builder.AddServiceDefaults(); + +// Add services to the container. +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +app.MapDefaultEndpoints(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + + +app.MapGet("/", () => +{ + return Results.Ok( "Get Information about user profile"); +}) +.WithName("GetProfile") +.WithOpenApi(); + + +app.Run(); diff --git a/samples/AspireWithYarp/ProfileMicroservice/Properties/launchSettings.json b/samples/AspireWithYarp/ProfileMicroservice/Properties/launchSettings.json new file mode 100644 index 00000000..7fbfeb18 --- /dev/null +++ b/samples/AspireWithYarp/ProfileMicroservice/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:46948", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5056", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/samples/AspireWithYarp/ProfileMicroservice/appsettings.Development.json b/samples/AspireWithYarp/ProfileMicroservice/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/ProfileMicroservice/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/ProfileMicroservice/appsettings.json b/samples/AspireWithYarp/ProfileMicroservice/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/samples/AspireWithYarp/ProfileMicroservice/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj b/samples/AspireWithYarp/PublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj new file mode 100644 index 00000000..d4b07626 --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/BlazorPublicSiteBetaVersion.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Components/App.razor b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/App.razor new file mode 100644 index 00000000..40d37a33 --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/App.razor @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor new file mode 100644 index 00000000..0fd1b20e --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor @@ -0,0 +1,9 @@ +@inherits LayoutComponentBase + +@Body + +
+ An unhandled error has occurred. + Reload + 🗙 +
diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor.css b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor.css new file mode 100644 index 00000000..df8c10ff --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Layout/MainLayout.razor.css @@ -0,0 +1,18 @@ +#blazor-error-ui { + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + + #blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; + } diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Error.razor b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Error.razor new file mode 100644 index 00000000..576cc2d2 --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Error.razor @@ -0,0 +1,36 @@ +@page "/Error" +@using System.Diagnostics + +Error + +

Error.

+

An error occurred while processing your request.

+ +@if (ShowRequestId) +{ +

+ Request ID: @RequestId +

+} + +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+ +@code{ + [CascadingParameter] + private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Home.razor b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Home.razor new file mode 100644 index 00000000..76c832aa --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Pages/Home.razor @@ -0,0 +1,7 @@ +@page "/" + +Home + +

Hello, world!

+ +Welcome to the beta site! \ No newline at end of file diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Routes.razor b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Routes.razor new file mode 100644 index 00000000..d0df7816 --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/Routes.razor @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Components/_Imports.razor b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/_Imports.razor new file mode 100644 index 00000000..cea2d85f --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Components/_Imports.razor @@ -0,0 +1,10 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using BlazorPublicSiteBetaVersion +@using BlazorPublicSiteBetaVersion.Components \ No newline at end of file diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Program.cs b/samples/AspireWithYarp/PublicSiteBetaVersion/Program.cs new file mode 100644 index 00000000..c6485657 --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Program.cs @@ -0,0 +1,38 @@ +using BlazorPublicSiteBetaVersion.Components; + +namespace PublicSiteBetaVersion; + +public class Program +{ + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + builder.AddServiceDefaults(); + + // Add services to the container. + builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + + var app = builder.Build(); + + app.MapDefaultEndpoints(); + + // Configure the HTTP request pipeline. + if (!app.Environment.IsDevelopment()) + { + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); + } + + app.UseHttpsRedirection(); + + app.UseStaticFiles(); + app.UseAntiforgery(); + + app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + + app.Run(); + } +} diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/Properties/launchSettings.json b/samples/AspireWithYarp/PublicSiteBetaVersion/Properties/launchSettings.json new file mode 100644 index 00000000..cdf296b4 --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:21916", + "sslPort": 44345 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5104", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7100;http://localhost:5104", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } + } diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.Development.json b/samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.json b/samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/AspireWithYarp/PublicSiteBetaVersion/wwwroot/app.css b/samples/AspireWithYarp/PublicSiteBetaVersion/wwwroot/app.css new file mode 100644 index 00000000..e398853b --- /dev/null +++ b/samples/AspireWithYarp/PublicSiteBetaVersion/wwwroot/app.css @@ -0,0 +1,29 @@ +h1:focus { + outline: none; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid #e50000; +} + +.validation-message { + color: #e50000; +} + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + + .blazor-error-boundary::after { + content: "An error has occurred." + } + +.darker-border-checkbox.form-check-input { + border-color: #929292; +} diff --git a/samples/AspireWithYarp/YarpApiGateway/Program.cs b/samples/AspireWithYarp/YarpApiGateway/Program.cs new file mode 100644 index 00000000..6a486a3a --- /dev/null +++ b/samples/AspireWithYarp/YarpApiGateway/Program.cs @@ -0,0 +1,15 @@ +var builder = WebApplication.CreateBuilder(args); + +builder.AddServiceDefaults(); + +builder.Services.AddReverseProxy() + .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")) + .AddServiceDiscoveryDestinationResolver(); + +var app = builder.Build(); + + +app.MapReverseProxy(); + + +app.Run(); diff --git a/samples/AspireWithYarp/YarpApiGateway/Properties/launchSettings.json b/samples/AspireWithYarp/YarpApiGateway/Properties/launchSettings.json new file mode 100644 index 00000000..92126c64 --- /dev/null +++ b/samples/AspireWithYarp/YarpApiGateway/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:31419", + "sslPort": 44315 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5039", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7290;http://localhost:5039", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swaggers", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.csproj b/samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.csproj new file mode 100644 index 00000000..de56ccf3 --- /dev/null +++ b/samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.http b/samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.http new file mode 100644 index 00000000..77edf5f4 --- /dev/null +++ b/samples/AspireWithYarp/YarpApiGateway/YarpApiGateway.http @@ -0,0 +1,6 @@ +@YarpApiGateway_HostAddress = http://localhost:5039 + +GET {{YarpApiGateway_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/samples/AspireWithYarp/YarpApiGateway/appsettings.Development.json b/samples/AspireWithYarp/YarpApiGateway/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/YarpApiGateway/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/YarpApiGateway/appsettings.json b/samples/AspireWithYarp/YarpApiGateway/appsettings.json new file mode 100644 index 00000000..04c513d1 --- /dev/null +++ b/samples/AspireWithYarp/YarpApiGateway/appsettings.json @@ -0,0 +1,53 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "ReverseProxy": { + "Routes": { + "feedRoute": { + "ClusterId": "feeds", + "Match": { + "Path": "/feed/{**catch-all}" + }, + "Transforms": [ + { + "PathRemovePrefix": "/feed" + } + ] + }, + "profileRoute": { + "ClusterId": "profiles", + "Match": { + "Path": "/profile/{**catch-all}" + }, + "Transforms": [ + { + "PathRemovePrefix": "/profile" + } + ] + } + }, + "Clusters": { + "feeds": { + "Destinations": { + "destination1": { + "Address": "http://feed", + "Health": "http://feed/readiness" + } + } + }, + "profiles": { + "Destinations": { + "destination1": { + "Address": "http://profile", + "Health": "http://profile/readiness" + } + } + } + } + } +} diff --git a/samples/AspireWithYarp/YarpIngress/Program.cs b/samples/AspireWithYarp/YarpIngress/Program.cs new file mode 100644 index 00000000..6a486a3a --- /dev/null +++ b/samples/AspireWithYarp/YarpIngress/Program.cs @@ -0,0 +1,15 @@ +var builder = WebApplication.CreateBuilder(args); + +builder.AddServiceDefaults(); + +builder.Services.AddReverseProxy() + .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")) + .AddServiceDiscoveryDestinationResolver(); + +var app = builder.Build(); + + +app.MapReverseProxy(); + + +app.Run(); diff --git a/samples/AspireWithYarp/YarpIngress/Properties/launchSettings.json b/samples/AspireWithYarp/YarpIngress/Properties/launchSettings.json new file mode 100644 index 00000000..375e8067 --- /dev/null +++ b/samples/AspireWithYarp/YarpIngress/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:20717", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "", + "applicationUrl": "http://localhost:5024", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/samples/AspireWithYarp/YarpIngress/YarpIngress.csproj b/samples/AspireWithYarp/YarpIngress/YarpIngress.csproj new file mode 100644 index 00000000..0a1c27f4 --- /dev/null +++ b/samples/AspireWithYarp/YarpIngress/YarpIngress.csproj @@ -0,0 +1,19 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/YarpIngress/YarpIngress.http b/samples/AspireWithYarp/YarpIngress/YarpIngress.http new file mode 100644 index 00000000..7273848b --- /dev/null +++ b/samples/AspireWithYarp/YarpIngress/YarpIngress.http @@ -0,0 +1,6 @@ +@YarpIngress_HostAddress = http://localhost:5024 + +GET {{YarpIngress_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/samples/AspireWithYarp/YarpIngress/appsettings.Development.json b/samples/AspireWithYarp/YarpIngress/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/YarpIngress/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/YarpIngress/appsettings.json b/samples/AspireWithYarp/YarpIngress/appsettings.json new file mode 100644 index 00000000..7451fd53 --- /dev/null +++ b/samples/AspireWithYarp/YarpIngress/appsettings.json @@ -0,0 +1,48 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "ReverseProxy": { + "Routes": { + "public": { + "ClusterId": "cluster1", + "Match": { + "Path": "{**catch-all}" + } + }, + "beta": { + "ClusterId": "cluster2", + "Match": { + "Path": "/beta/{**catch-all}" + }, + "Transforms": [ + { + "PathRemovePrefix": "/beta" + } + ] + } + }, + "Clusters": { + "cluster1": { + "Destinations": { + "destination1": { + "Address": "http://publicsite", + "Health": "http://publicsite/readiness" + } + } + }, + "cluster2": { + "Destinations": { + "destination2": { + "Address": "http://publicsitebetaversion", + "Health": "http://publicsitebetaversion/readiness" + } + } + } + } + } +} diff --git a/samples/AspireWithYarp/blazor-public-site/BlazorPublicSite.csproj b/samples/AspireWithYarp/blazor-public-site/BlazorPublicSite.csproj new file mode 100644 index 00000000..f40dcea8 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/BlazorPublicSite.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + BlazorPublicSite + $(AssemblyName.Replace(' ', '_')) + + + + + + + diff --git a/samples/AspireWithYarp/blazor-public-site/Components/App.razor b/samples/AspireWithYarp/blazor-public-site/Components/App.razor new file mode 100644 index 00000000..ee702e2b --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Components/App.razor @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor b/samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor new file mode 100644 index 00000000..9d5318ff --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor @@ -0,0 +1,9 @@ +@inherits LayoutComponentBase + +@Body + +@*
+ An unhandled error has occurred. + Reload + 🗙 +
*@ diff --git a/samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor.css b/samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor.css new file mode 100644 index 00000000..df8c10ff --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Components/Layout/MainLayout.razor.css @@ -0,0 +1,18 @@ +#blazor-error-ui { + background: lightyellow; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); + display: none; + left: 0; + padding: 0.6rem 1.25rem 0.7rem 1.25rem; + position: fixed; + width: 100%; + z-index: 1000; +} + + #blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: 0.75rem; + top: 0.5rem; + } diff --git a/samples/AspireWithYarp/blazor-public-site/Components/Pages/Error.razor b/samples/AspireWithYarp/blazor-public-site/Components/Pages/Error.razor new file mode 100644 index 00000000..576cc2d2 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Components/Pages/Error.razor @@ -0,0 +1,36 @@ +@page "/Error" +@using System.Diagnostics + +Error + +

Error.

+

An error occurred while processing your request.

+ +@if (ShowRequestId) +{ +

+ Request ID: @RequestId +

+} + +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+ +@code{ + [CascadingParameter] + private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/samples/AspireWithYarp/blazor-public-site/Components/Pages/Home.razor b/samples/AspireWithYarp/blazor-public-site/Components/Pages/Home.razor new file mode 100644 index 00000000..ccb15f11 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Components/Pages/Home.razor @@ -0,0 +1,28 @@ +@page "/" +@inject FeedService FeedService + +Home + + +@code { + string messageFromFeedApi = string.Empty; + + protected override async Task OnInitializedAsync() + { + messageFromFeedApi = await FeedService.GetFeedMessage(); + } +} + + +

Welcome To the Public Site 😃

+ +Welcome to the public site! You are here because of the yarp ingress. + + +

+ This version of the site is utilizing the feed api that is running behind the api gateway. here is the message from the feed microservice +

+ + +Here: @messageFromFeedApi + \ No newline at end of file diff --git a/samples/AspireWithYarp/blazor-public-site/Components/Routes.razor b/samples/AspireWithYarp/blazor-public-site/Components/Routes.razor new file mode 100644 index 00000000..d0df7816 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Components/Routes.razor @@ -0,0 +1,6 @@ + + + + + + diff --git a/samples/AspireWithYarp/blazor-public-site/Components/_Imports.razor b/samples/AspireWithYarp/blazor-public-site/Components/_Imports.razor new file mode 100644 index 00000000..84202740 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Components/_Imports.razor @@ -0,0 +1,11 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using BlazorPublicSite +@using BlazorPublicSite.Components +@using BlazorPublicSite.Services diff --git a/samples/AspireWithYarp/blazor-public-site/Program.cs b/samples/AspireWithYarp/blazor-public-site/Program.cs new file mode 100644 index 00000000..cba0d621 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Program.cs @@ -0,0 +1,37 @@ +using BlazorPublicSite.Components; +using BlazorPublicSite.Services; + +namespace BlazorPublicSite; + +public class Program +{ + public static void Main(string[] args) + { + var builder = WebApplication.CreateBuilder(args); + builder.AddServiceDefaults(); + + builder.Services.AddHttpClient(static client => client.BaseAddress = new Uri("http://apigateway/feed")); + + // Add services to the container. + builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + + var app = builder.Build(); + + app.MapDefaultEndpoints(); + + // Configure the HTTP request pipeline. + if (!app.Environment.IsDevelopment()) + { + app.UseExceptionHandler("/Error"); + } + + app.UseStaticFiles(); + app.UseAntiforgery(); + + app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + + app.Run(); + } +} diff --git a/samples/AspireWithYarp/blazor-public-site/Properties/launchSettings.json b/samples/AspireWithYarp/blazor-public-site/Properties/launchSettings.json new file mode 100644 index 00000000..a689413b --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:21914", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5224", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } + } diff --git a/samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs b/samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs new file mode 100644 index 00000000..8b8f9121 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs @@ -0,0 +1,10 @@ +namespace BlazorPublicSite.Services; + +public class FeedService(HttpClient httpClient) +{ + public async Task GetFeedMessage() + { + var response = await httpClient.GetAsync("/"); + return await response.Content.ReadAsStringAsync(); + } +} diff --git a/samples/AspireWithYarp/blazor-public-site/appsettings.Development.json b/samples/AspireWithYarp/blazor-public-site/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/samples/AspireWithYarp/blazor-public-site/appsettings.json b/samples/AspireWithYarp/blazor-public-site/appsettings.json new file mode 100644 index 00000000..10f68b8c --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/AspireWithYarp/blazor-public-site/wwwroot/app.css b/samples/AspireWithYarp/blazor-public-site/wwwroot/app.css new file mode 100644 index 00000000..e398853b --- /dev/null +++ b/samples/AspireWithYarp/blazor-public-site/wwwroot/app.css @@ -0,0 +1,29 @@ +h1:focus { + outline: none; +} + +.valid.modified:not([type=checkbox]) { + outline: 1px solid #26b050; +} + +.invalid { + outline: 1px solid #e50000; +} + +.validation-message { + color: #e50000; +} + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + + .blazor-error-boundary::after { + content: "An error has occurred." + } + +.darker-border-checkbox.form-check-input { + border-color: #929292; +} From 2a9028e0a68f81bcd8708ce5c3eaefdeb8f62567 Mon Sep 17 00:00:00 2001 From: Joe Whiteaker <47674962+josephaw1022@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:59:37 -0500 Subject: [PATCH 2/2] fixed 404 error --- samples/AspireWithYarp/blazor-public-site/Program.cs | 2 +- .../AspireWithYarp/blazor-public-site/Services/FeedService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/AspireWithYarp/blazor-public-site/Program.cs b/samples/AspireWithYarp/blazor-public-site/Program.cs index cba0d621..868244ca 100644 --- a/samples/AspireWithYarp/blazor-public-site/Program.cs +++ b/samples/AspireWithYarp/blazor-public-site/Program.cs @@ -10,7 +10,7 @@ public static void Main(string[] args) var builder = WebApplication.CreateBuilder(args); builder.AddServiceDefaults(); - builder.Services.AddHttpClient(static client => client.BaseAddress = new Uri("http://apigateway/feed")); + builder.Services.AddHttpClient(static client => client.BaseAddress = new Uri("http://apigateway")); // Add services to the container. builder.Services.AddRazorComponents() diff --git a/samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs b/samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs index 8b8f9121..b7e195de 100644 --- a/samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs +++ b/samples/AspireWithYarp/blazor-public-site/Services/FeedService.cs @@ -4,7 +4,7 @@ public class FeedService(HttpClient httpClient) { public async Task GetFeedMessage() { - var response = await httpClient.GetAsync("/"); + var response = await httpClient.GetAsync("/feed"); return await response.Content.ReadAsStringAsync(); } }