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

server

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: 77 Imported by: 0

Documentation

Overview

Package server builds the single chi router that serves every JFrog path prefix: /artifactory, /access, /event, /router, /jfconnect and /v2. Flat CRUD families come from the generated strict servers; item paths and protocol handlers are hand-written and mounted first (decision 0002).

Index

Constants

View Source
const DefaultRedirectTTL = 5 * time.Minute

DefaultRedirectTTL is how long a signed download URL stays valid when Config.Redirect sets no TTL.

Variables

This section is empty.

Functions

func New

func New(cfg Config) http.Handler

New returns the fully wired handler.

func OriginalContentType

func OriginalContentType(ctx context.Context) string

OriginalContentType returns the vendor media type a client sent before normalizeContentType rewrote it, or "" when the client sent a plain type.

Types

type AQLLimits

type AQLLimits struct {
	// MaxResults caps the rows of every query, its own limit included; zero
	// means no cap.
	MaxResults int
	// ScanFactor multiplies a non-admin query's limit, so that limit can
	// still be met once rows the caller may not read are dropped. Below 1
	// is 1. A request's scan-factor header above 1 overrides it.
	ScanFactor int
	// Timeout cancels a query's database work after this long, and
	// StreamTimeout one sent with a stream: true header; zero means no
	// timeout. The answer is then 408.
	Timeout, StreamTimeout time.Duration
}

AQLLimits bounds POST /api/search/aql (decision 0012).

type Config

type Config struct {
	// BaseURL is the operator-configured public base URL; empty means derive
	// it from the request. Override and X-Forwarded-* headers take precedence.
	BaseURL string
	// CompatVersion is the Artifactory version reported to clients; it gates
	// client features, so it is configuration rather than the build version.
	CompatVersion string
	// Revision is the real artifactweave build identifier.
	Revision string
	// Logger receives access and panic logs; nil falls back to slog.Default so
	// tests and library users need not wire one.
	Logger *slog.Logger
	// Store is the metadata store and Blobs the blob store that the content
	// handlers read and write. ColdBlobs is the archive tier, nil when none
	// is configured.
	Store     store.Store
	Blobs     blob.Store
	ColdBlobs blob.Store
	// GC is the garbage collector the runtime schedules; POST
	// /api/system/storage/gc runs the same one. Nil builds one per request,
	// for tests.
	GC *gc.Collector
	// BlobLocation describes the hot blob store in the storage summary.
	BlobLocation usage.Location
	// Auth verifies credentials. Nil serves every route without
	// authentication, which only tests do: such a handler has no store and
	// answers just the system endpoints and the stubs.
	Auth *auth.Authenticator
	// Mirrors administers the blob mirrors; nil when no tier is a mirror.
	Mirrors Mirrors
	// Multipart serves the JFrog CLI's multipart upload protocol; nil
	// reports it unsupported, so the CLI uploads in one request.
	Multipart *multipart.Service
	// Tokens issues, refreshes and revokes access tokens for the token API;
	// nil answers that API 501.
	Tokens *token.Service
	// AllowBasicAuthTokens lets a password sent with Basic create tokens
	// through POST /access/api/v1/tokens (token.allow_basic_auth); the zero
	// value refuses it, as Artifactory 7.x does by default.
	AllowBasicAuthTokens bool
	// PasswordHash is the cost of passwords the security API sets; the zero
	// value is production's. Only Go code can choose another: tests use a
	// tiny cost.
	PasswordHash auth.HashParams
	// Redirect tunes downloadRedirect and cdnRedirect (decision 0029).
	Redirect Redirect
	// FolderDownloadMaxConcurrent is how many folder archive downloads run
	// at once (download.folder.max_concurrent_requests); zero means
	// Artifactory's 10.
	FolderDownloadMaxConcurrent int
	// AQL bounds AQL searches; the zero value has no cap. Its MaxResults
	// caps the GET searches too.
	AQL AQLLimits
	// Search limits what the GET searches return; the zero value limits
	// nothing.
	Search SearchLimits
	// DockerSubdomainMatch turns on the Docker subdomain method
	// (docker.subdomain_match): <repo>.<BaseURL host>/v2/... addresses repo.
	DockerSubdomainMatch bool
	// AllowDuplicateBuildEntries accepts a build-info publish whose module
	// lists one file twice (build.block_duplicate_entries false); the zero
	// value refuses it, as Artifactory 7.x does by default.
	AllowDuplicateBuildEntries bool
	// EnforceIdenticalChecksumDeploy makes a checksum deploy over a file
	// with the same content need the delete permission
	// (deploy.enforce_permission_check_on_identical_checksum_deploy); the
	// zero value lets it through with deploy alone, as Artifactory 7.x does
	// by default.
	EnforceIdenticalChecksumDeploy bool
	// NPMLoginTokenExpiry is how long a token from npm login lasts
	// (npm.login_token_expiry); zero means decision 0034's default.
	NPMLoginTokenExpiry time.Duration
	// NPMMaxPublishSize caps an npm publish request (npm.max_publish_size);
	// zero means decision 0034's default.
	NPMMaxPublishSize int64
	// GlobalEnvironmentLimit caps the global environments, DEV and PROD
	// included (environments.global_limit); zero means
	// roles.DefaultGlobalEnvironmentLimit.
	GlobalEnvironmentLimit int
	// Work is the runtime's work queue, which formats ask for derived work
	// (decision 0033). Nil writes that work to the store's queue directly,
	// where the workers find it on their next poll.
	Work *work.Queue
	// Formats returns a package type's format; nil means
	// FormatSettings.For. Only tests set it, to substitute formats that
	// record their hooks.
	Formats func(repo.PackageType) format.Handler
	// FormatSettings are the formats' server-wide options, such as
	// npm.tag_latest_by_publish; the zero value is each format's default.
	FormatSettings formats.Settings
	// Protocols are mounted through the router kit after the built-in ones
	// (protocols). Only tests set it, to mount a test-only protocol.
	Protocols []pkgroute.Protocol
}

Config is what the router needs from the application configuration.

type MirrorStatus

type MirrorStatus struct {
	Tier string
	mirror.Status
}

MirrorStatus is one tier's mirror: "blob" or "cold_blob".

type Mirrors

type Mirrors interface {
	// Optimize asks every mirror for an immediate repair pass.
	Optimize()
	// Status returns each mirror's status.
	Status(ctx context.Context) ([]MirrorStatus, error)
}

Mirrors is what the storage endpoints need from the runtime's blob mirrors (#18).

type Redirect

type Redirect struct {
	// MinSize is the smallest file that redirects; zero redirects every file.
	// A descriptor's downloadRedirectConfig.fileMinimumSize, once applied,
	// takes its place.
	MinSize int64
	// TTL is how long a signed URL stays valid once handed out; zero means
	// DefaultRedirectTTL.
	TTL time.Duration
	// CDNMaxSize is the largest file sent to the CDN; a larger one goes to
	// storage under downloadRedirect and streams otherwise. Zero means no
	// limit. The application sets cdn.CloudFrontMaxSize when the blob store
	// has a CloudFront distribution.
	CDNMaxSize int64
}

Redirect tunes the download redirect policy.

type SearchLimits

type SearchLimits struct {
	// UserQueryLimit caps the results anonymous callers get, and every
	// non-admin's when LimitInternalUsers is set; zero means no cap.
	UserQueryLimit int
	// LimitInternalUsers applies UserQueryLimit to signed-in non-admins too.
	LimitInternalUsers bool
}

SearchLimits bounds the GET searches, as Artifactory's artifactory.search.userQueryLimit and limitAnonymousUsersOnly do.

Directories

Path Synopsis
Package apierror renders errors in the envelope each client surface expects.
Package apierror renders errors in the envelope each client surface expects.
Package baseurl resolves the public base URL a response must embed.
Package baseurl resolves the public base URL a response must embed.
Package docker serves the registry protocol, the OCI Distribution Specification v1.1 with Docker's extensions, for docker, oci and helmoci repositories (decisions 0003 and 0031).
Package docker serves the registry protocol, the OCI Distribution Specification v1.1 with Docker's extensions, for docker, oci and helmoci repositories (decisions 0003 and 0031).
gen
access
Package access provides primitives to interact with the openapi HTTP API.
Package access provides primitives to interact with the openapi HTTP API.
artifactory
Package artifactory provides primitives to interact with the openapi HTTP API.
Package artifactory provides primitives to interact with the openapi HTTP API.
distribution
Package distribution provides primitives to interact with the openapi HTTP API.
Package distribution provides primitives to interact with the openapi HTTP API.
event
Package event provides primitives to interact with the openapi HTTP API.
Package event provides primitives to interact with the openapi HTTP API.
grid
Package grid provides primitives to interact with the openapi HTTP API.
Package grid provides primitives to interact with the openapi HTTP API.
pfed
Package pfed provides primitives to interact with the openapi HTTP API.
Package pfed provides primitives to interact with the openapi HTTP API.
worker
Package worker provides primitives to interact with the openapi HTTP API.
Package worker provides primitives to interact with the openapi HTTP API.
Package golang serves Go module repositories at /artifactory/api/go/{repoKey}/ through the router kit (decisions 0032 and 0035): the GOPROXY reads the go command makes, and the deploys of jf go-publish.
Package golang serves Go module repositories at /artifactory/api/go/{repoKey}/ through the router kit (decisions 0032 and 0035): the GOPROXY reads the go command makes, and the deploys of jf go-publish.
Package npm serves the npm registry of npm repositories at /artifactory/api/npm/{repoKey}/ (decision 0034), mounted through the router kit (decision 0032).
Package npm serves the npm registry of npm repositories at /artifactory/api/npm/{repoKey}/ (decision 0034), mounted through the router kit (decision 0032).
Package pkgroute is the router kit for package formats with a protocol of their own: npm and Go in P7, then PyPI, NuGet, Helm and Terraform (decision 0032).
Package pkgroute is the router kit for package formats with a protocol of their own: npm and Go in P7, then PyPI, NuGet, Helm and Terraform (decision 0032).

Jump to

Keyboard shortcuts

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