handler

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderGatewayInitator = "X-Gateway-Initator"

HeaderGatewayInitator is the request-header name the auth middleware expects to carry caller identity. The misspelling (missing the second 'i' in "Initator") is deliberate — it matches the existing caller-side convention and is part of the frozen public contract. Do not "fix" it.

View Source
const HeaderGatewaySecret = "X-Gateway-Secret"

HeaderGatewaySecret is the request-header name the auth middleware expects to carry the shared secret value.

Variables

This section is empty.

Functions

func NewFilesDeleteHandler

func NewFilesDeleteHandler(g git.Git) libhttp.WithError

NewFilesDeleteHandler returns a WithError handler that deletes a file from the git repository.

func NewFilesDispatchHandler added in v0.6.2

func NewFilesDispatchHandler(getH, listH http.Handler) http.Handler

NewFilesDispatchHandler routes GET /api/v1/files/ to listH when the glob query parameter is present, and to getH otherwise.

func NewFilesGetHandler

func NewFilesGetHandler(g git.Git) libhttp.WithError

NewFilesGetHandler returns a WithError handler that reads a file from the git repository.

func NewFilesListHandler

func NewFilesListHandler(g git.Git) libhttp.WithError

NewFilesListHandler returns a WithError handler that lists files in the git repository matching a glob pattern.

func NewFilesPostHandler

func NewFilesPostHandler(g git.Git) libhttp.WithError

NewFilesPostHandler returns a WithError handler that writes a file to the git repository. When the request carries ?create_only=1, the write is create-only: an already-occupied path returns 409 Conflict instead of overwriting the existing file.

func NewGatewaySecretMiddleware added in v0.17.0

func NewGatewaySecretMiddleware(secret string) func(http.Handler) http.Handler

NewGatewaySecretMiddleware returns a gorilla mux-compatible middleware (func(http.Handler) http.Handler) that enforces shared-secret header auth.

Check order (first failure wins):

  1. X-Gateway-Initator missing or empty → 500 (initiator identity required)
  2. X-Gateway-Secret missing, empty, or not equal to secret → 401
  3. Both present and matching → strip X-Gateway-Secret, call next

"Missing" and "empty string" are treated identically for both headers: r.Header.Get returning "" triggers the same response regardless of whether the client omitted the header or sent an empty value.

X-Gateway-Secret is deleted from the request before the inner handler is called so it cannot appear in downstream request logs or metrics labels.

func NewMetricsMiddleware added in v0.6.2

func NewMetricsMiddleware(m metrics.Metrics, next http.Handler) http.Handler

NewMetricsMiddleware wraps next with Prometheus HTTP request counting.

func NewReadinessHandler

func NewReadinessHandler(s ReadinessStateReader) libhttp.WithError

NewReadinessHandler returns a handler that reports readiness based on cached pull state. It never invokes a git subprocess and never blocks on the pull mutex.

Types

type ReadinessStateReader added in v0.19.1

type ReadinessStateReader interface {
	ReadinessStatus() (bool, string)
}

ReadinessStateReader is the interface the readiness handler reads from. Implemented by *puller.PullStateCache.

Jump to

Keyboard shortcuts

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