middleware

package
v1.40.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package middleware provides HTTP middleware functions for Packhorse.

Index

Constants

View Source
const (
	// HeaderGitalyCorrelationID is where GitLab Runner puts a job's correlation ID
	// on git HTTP requests. The runner sets it with
	// `git config http.extraHeader`, gated behind FF_USE_GITALY_CORRELATION_ID
	// (default true), and prints the same value in the job trace as
	// "Gitaly correlation ID: <id>". It is therefore the ID an operator has in hand
	// when a CI job fails with a git error.
	//
	// The value is the correlation ID of the runner's POST /api/v4/jobs/request
	// call — GitLab's X-Request-Id from that response, or a UUID the runner minted
	// itself if the response carried none. It is held on the job, so it stays
	// constant across every git request the job makes, including fetch retries.
	//
	// The runner spells it X-Gitaly-Correlation-ID on the wire. Written here in Go's
	// canonical form instead, which Header.Get and Header.Set both normalise to, so
	// the two match.
	HeaderGitalyCorrelationID = "X-Gitaly-Correlation-Id"
)

Variables

This section is empty.

Functions

func AdoptGitalyCorrelationID added in v1.40.0

func AdoptGitalyCorrelationID(next http.Handler) http.Handler

AdoptGitalyCorrelationID copies X-Gitaly-Correlation-ID into X-Request-Id when the request has no X-Request-Id of its own. The adopted value is deliberately not validated here, since CorrelationIDMiddleware validate it.

func Allowlist

func Allowlist(list *allowlist.Allowlist, fallback http.Handler) func(http.Handler) http.Handler

Allowlist wraps allowlist.Allowlist in a HTTP middleware. Requests for repositories not on the list are sent to fallback, which proxies them straight to the upstream without consulting the cache.

When list is nil or its disabled flag is set, every request flows through to next — see allowlist.Allowlist.Allowed.

func ProtocolV2

func ProtocolV2(next http.Handler) http.Handler

ProtocolV2 is HTTP middleware that enforces Git Protocol v2. It checks for the Git-Protocol header with value "version=2". Returns 400 Bad Request if missing or has different value.

This middleware should be applied to Git protocol routes but not to API routes that don't require Git protocol headers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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