Help us shape the future of Go! Take the 2026 Go Developer Survey

baseurl

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package baseurl resolves the public base URL a response must embed.

npm tarball links, Helm chart URLs, the NuGet service index, Terraform download URLs, Docker upload locations and file-info URIs all carry absolute URLs. Behind a reverse proxy the request's own host is wrong, so the resolver follows Artifactory's precedence (OSS 6.20 HttpUtils.getServletContextUrl, research 17): the X-JFrog-Override-Base-Url header, then the configured base URL, then the X-Forwarded-* headers, then the request. A configured base URL is the operator naming the public URL, so a request header the operator does not control never overrides it (#313). Every handler reads the result from the context so there is exactly one place that implements the rule (decision 0002).

Index

Constants

View Source
const OverrideHeader = "X-JFrog-Override-Base-Url"

OverrideHeader is the header Artifactory clients and proxies use to force the base URL for one request.

Variables

This section is empty.

Functions

func ForwardedHost

func ForwardedHost(r *http.Request) string

ForwardedHost is the host the client addressed as the outermost proxy saw it: the first entry of X-Forwarded-Host, or "" when there is none. Each proxy in a chain appends the host it received, so the first entry is the client-facing one and later entries are internal (research 17). An empty first entry names no host, so it is ignored rather than trusting a later, internal one.

func From

func From(ctx context.Context) string

From returns the base URL stored by Middleware, or "" when the middleware did not run. Callers treat "" as a programming error, not a fallback.

func Middleware

func Middleware(configured string) func(http.Handler) http.Handler

Middleware stores the resolved base URL in the request context.

func Resolve

func Resolve(r *http.Request, configured string) string

Resolve returns the base URL for r without a trailing slash. configured is the operator-supplied base URL and may be empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL