Make built-in upstream URLs configurable - #255
Open
andrew wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes built-in ecosystem upstream URLs configurable via the upstream YAML/JSON block and corresponding PROXY_UPSTREAM_* environment variables, while keeping existing defaults and existing constructor signatures intact. It updates handlers that previously hard-coded upstream hosts (or assumed single-host services) to accept resolved upstreams, including protocols with separate API/download/search endpoints.
Changes:
- Expand
UpstreamConfigdefaults and environment-variable loading to cover all built-in routes (and multi-service protocols). - Add
WithUpstream(s)constructors across handlers and wire them intointernal/serverstartup. - Update docs/examples and add tests validating configured-upstream behavior and URL rewriting (PyPI, NuGet, Hex API).
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Links to the upstream configuration reference section. |
| internal/server/server.go | Wires resolved upstream URLs into handler construction for built-in routes. |
| internal/handler/upstream_test.go | Adds tests asserting constructor wiring and upstream-dependent behaviors (Hex API, PyPI rewrite, NuGet search). |
| internal/handler/rpm.go | Adds configurable upstream constructor for RPM handler. |
| internal/handler/pypi.go | Splits PyPI API vs download upstreams; rewrites links/JSON based on configured download upstream. |
| internal/handler/pub.go | Adds configurable upstream constructor for Pub handler. |
| internal/handler/nuget.go | Splits NuGet API vs search upstreams; rewrites service index based on service type and uses configured search upstream. |
| internal/handler/nuget_test.go | Updates tests for new NuGet rewrite method signature/type-based rewriting. |
| internal/handler/julia.go | Adds configurable upstream constructor for Julia handler. |
| internal/handler/hex.go | Adds configurable repo vs API upstreams and uses configured API host for cooldown lookups. |
| internal/handler/handler.go | Adds helper to resolve/normalize configured upstream URLs. |
| internal/handler/go.go | Adds configurable upstream constructor for Go handler. |
| internal/handler/gem.go | Adds configurable upstream constructor for RubyGems handler. |
| internal/handler/cran.go | Adds configurable upstream constructor for CRAN handler. |
| internal/handler/container.go | Adds configurable default OCI registry constructor for container handler. |
| internal/handler/conda.go | Adds configurable upstream constructor for Conda handler. |
| internal/handler/conan.go | Adds configurable upstream constructor for Conan handler. |
| internal/handler/composer.go | Adds configurable API vs repository upstreams for Composer/Packagist handler. |
| internal/config/config.go | Extends UpstreamConfig schema/defaults and adds PROXY_UPSTREAM_* env overrides for all upstream keys. |
| internal/config/config_test.go | Adds/updates tests for upstream defaults, YAML/JSON loading, and env override coverage. |
| docs/configuration.md | Documents every upstream key/env var/default and provides chaining examples. |
| config.example.yaml | Adds all upstream keys (with defaults) to the example configuration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+50
to
+55
| func configuredUpstreamURL(value, defaultValue string) string { | ||
| if value == "" { | ||
| value = defaultValue | ||
| } | ||
| return strings.TrimSuffix(value, "/") | ||
| } |
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.
Makes every built-in package upstream configurable through the
upstreamYAML or JSON block and matchingPROXY_UPSTREAM_*environment variables.Existing defaults and constructor signatures remain unchanged. Protocols with separate services expose distinct settings, and PyPI and NuGet URL rewriting follows configured upstreams so one proxy can use another as its upstream.
The
upstreamblock remains the configuration layer for built-in routes. A future route model such as #93 can use these resolved values for its default routes while keeping custom route topology separate.The configuration example and reference list every key, environment variable, and default.