api

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

Documentation

Overview

Package api provides HTTP API handlers for Packhorse's management endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RegisterRequest

type RegisterRequest struct {
	Repository    string `json:"repository"`
	PackfileURI   string `json:"packfile_uri"`
	HashAlgorithm string `json:"hash_algorithm"`
	PackfileHash  string `json:"packfile_hash"`
}

RegisterRequest represents the JSON request body for registering a base packfile.

type RegisterResponse

type RegisterResponse struct {
	Repository string `json:"repository"`
	State      string `json:"state"`
	Message    string `json:"message"`
}

RegisterResponse represents the JSON response after registering a base packfile.

type RegistrationHandler

type RegistrationHandler struct {
	// contains filtered or unexported fields
}

RegistrationHandler handles POST requests to register base packfiles.

func NewRegistrationHandler

func NewRegistrationHandler(manager packfile.BasePackfileManager, parser *packfile.BlobStorePackfileParser) *RegistrationHandler

NewRegistrationHandler creates a new registration handler.

func (*RegistrationHandler) ServeHTTP

func (h *RegistrationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP requests for base packfile registration. It expects a POST request with a JSON body containing:

  • repository: Repository path (e.g., "gitlab-org/gitlab")
  • packfile_uri: URI to .pack file in object storage
  • hash_algorithm: "sha1" or "sha256"
  • packfile_hash: Hash of the packfile (hex-encoded string)

Returns:

  • 202 Accepted: Registration successful, extraction will begin asynchronously
  • 400 Bad Request: Invalid request body or missing required fields
  • 500 Internal Server Error: Failed to register with manager

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router handles API routes under /-/api/git-cache/.

func New

New creates a new API router with all handlers registered. Routes are registered without the /-/api/git-cache prefix since the top-level mux uses http.StripPrefix to strip it before routing here.

Parameters:

  • manager: Base packfile manager for tracking packfiles
  • parser: Packfile parser for extracting commit OIDs (can be nil)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler interface.

Jump to

Keyboard shortcuts

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