Skip to content

Make built-in upstream URLs configurable - #255

Open
andrew wants to merge 1 commit into
mainfrom
configurable-upstreams
Open

Make built-in upstream URLs configurable#255
andrew wants to merge 1 commit into
mainfrom
configurable-upstreams

Conversation

@andrew

@andrew andrew commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Makes every built-in package upstream configurable through the upstream YAML or JSON block and matching PROXY_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 upstream block 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UpstreamConfig defaults and environment-variable loading to cover all built-in routes (and multi-service protocols).
  • Add WithUpstream(s) constructors across handlers and wire them into internal/server startup.
  • 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, "/")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants