Introduce structured configuration model for YARP container app#3017
Merged
Introduce structured configuration model for YARP container app#3017
Conversation
Replace ad-hoc config keys (YARP_ENABLE_STATIC_FILES, etc.) with a structured object model (YarpAppConfig) bound from IConfiguration. - Configuration/YarpAppConfig.cs: Root config POCO with all sections - Configuration/YarpAppConfigBinder.cs: Single IConfiguration -> object model conversion, with legacy key mapping - Features/: Modular extension methods per feature (StaticFiles, NavigationFallback, ReverseProxy) - Program.cs: Clean pipeline - ordering is explicit, feature logic is in extension methods - Extensions.cs: Takes YarpAppConfig instead of reading IConfiguration Legacy env vars (YARP_ENABLE_STATIC_FILES, YARP_DISABLE_SPA_FALLBACK, YARP_UNSAFE_OLTP_CERT_ACCEPT_ANY_SERVER_CERTIFICATE) continue to work. New config format: StaticFiles:Enabled=true NavigationFallback:Path=/index.html Refs #3015 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Set ContentRootPath and WebRootPath via WebApplicationOptions when a config file is passed, so the default wwwroot directory resolves relative to the config file's location. Add samples/StaticSite/ with index.html, 404.html, hashed CSS, and nested directory pages to exercise static file hosting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Print a clean startup summary showing config file, webroot, SPA fallback, and listening URLs. Suppress noisy framework logs (DataProtection, Hosting.Lifetime, etc.) on the console provider so docker logs shows only useful information. Banner writes to Console directly so it always shows regardless of log level. Framework logs still flow to other providers (OTEL). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the AddConfiguration pattern from Aspire to allow users to override our default console log suppression via the standard Logging:Console:LogLevel config section. Our defaults suppress framework noise, but users can re-enable specific categories when debugging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove unimplemented config sections (Compression, Https, Headers, Redirects, CleanUrls, TrailingSlash, PreCompressed, ErrorPages, NavigationFallback.Exclude) from the schema, options classes, binder, and README. These get added when their features are implemented. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…y path - Clear TestConfiguration AsyncLocal value after consuming to prevent test pollution between sequential tests - Handle Path.GetDirectoryName returning null for root paths by falling back to current directory - Improve README with startup banner example, logging docs, accurate project structure Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Was accidentally created by dotnet build. The repo uses YARP.slnx. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add language specifiers to fenced code blocks and fix table column spacing to pass markdownlint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add YarpAppConfig object model support to YarpTestApp: tests can construct config as strongly-typed objects that serialize to JSON - Add YarpAppConfigBinderTests: 13 unit tests covering new config format, legacy key mapping, precedence rules, and edge cases - Disable parallel test execution to prevent AsyncLocal race conditions - Update integration tests to demonstrate both object model and dictionary-based config patterns 27 tests total (14 integration + 13 binder unit tests) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AsyncLocal is per-execution-context, not per-thread. Each test's WebApplicationFactory runs in its own async context so parallel tests don't interfere with each other's config values. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
No need to pass IConfiguration separately — it's available on the builder. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MihaZupan
approved these changes
Apr 15, 2026
Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
Agent-Logs-Url: https://github.com/dotnet/yarp/sessions/539722f2-db88-4a86-9362-d5701423a238 Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
Contributor
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
MihaZupan
approved these changes
Apr 15, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces ad-hoc config keys (
YARP_ENABLE_STATIC_FILES,YARP_DISABLE_SPA_FALLBACK, etc.) with a structured configuration model for the YARP container application.What's included
Configuration model (#3015)
YarpAppConfigroot object bound fromIConfigurationat startup — single conversion pointStaticFilesOptions,NavigationFallbackOptions, etc.)YarpAppConfigBinderhandles theIConfiguration→ object model conversion + legacy key mappingyarp-config.schema.json) for IDE autocomplete and validationTestConfigurationusingAsyncLocalfor WebApplicationFactory test support (aspnetcore#37680)Modular feature pattern
Features/— keeps Program.cs cleanStartup banner and logging
Logging:Console:LogLevelescape hatch works (re-add configuration pattern from Aspire)Static site sample
samples/StaticSite/with index.html, 404.html, hashed CSS, nested pagesWebApplicationOptionsBackward compatible
Legacy env vars continue to work:
YARP_ENABLE_STATIC_FILES→StaticFiles:EnabledYARP_DISABLE_SPA_FALLBACK→ disablesNavigationFallback:PathYARP_UNSAFE_OLTP_CERT_ACCEPT_ANY_SERVER_CERTIFICATE→Telemetry:UnsafeAcceptAnyCertificateTesting
Related issues