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

githubapi

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package githubapi serves the subset of GitHub's REST API that the actions running on ermite call under github.api_url (/-/github/api, ADR 0025 CI-2):

GET /repos/{owner}/{repo}
GET /repos/{owner}/{repo}/hash-algorithm
GET /repos/{owner}/{repo}/tarball[/{ref}]
GET /repos/{owner}/{repo}/pulls/{number}/files   (dorny/paths-filter on pull_request)

Everything else under the prefix is GitHub's 404 JSON, so that an action calling an endpoint of a feature ermite lacks fails as it does on a GitHub instance without it, never silently succeeds. The auth is the forge's: a token (stored, or the repository token of a job) as the password of Basic with any user, or as "Bearer" or "token" credentials; no credentials is anonymous, which reads public repositories.

Index

Constants

View Source
const (
	// DefaultMaxArchives is the archives written at once on the server.
	DefaultMaxArchives = 16
	// DefaultMaxArchivesPerClient is the archives written at once for one client
	// (see clientlimit.Key). A runner host runs several jobs at once, each
	// downloading its actions, and all come from one address; eight is half of
	// the server's slots, so one host cannot take them all. Beyond it the answer
	// is 429 with Retry-After: the runner waits and tries again.
	DefaultMaxArchivesPerClient = 8
	// DefaultWriteIdleTimeout is how long a write of the archive may wait for the
	// client. The deadline moves forward with every chunk: an archive is bounded
	// by its size, not by its duration, but a client that stops reading is cut.
	DefaultWriteIdleTimeout = 2 * time.Minute
)

Bounds on the archives written at once.

View Source
const Prefix = "/-/github/api"

Prefix is where the API is mounted.

Variables

View Source
var Patterns = []string{Prefix + "/"}

Patterns are the ServeMux patterns the handler serves: its whole prefix.

Functions

This section is empty.

Types

type Config

type Config struct {
	Auth ports.AuthService
	API  ports.GitHubAPIService
	// TrustedProxies are the networks allowed to set X-Forwarded-For.
	TrustedProxies []netip.Prefix
	// Limiter counts failed authentications; nil builds a default one.
	Limiter ports.FailureLimiter
	// MaxArchives bounds the archives written at once (each runs a git
	// process); zero means DefaultMaxArchives. MaxArchivesPerClient bounds them
	// per client; zero means DefaultMaxArchivesPerClient. WriteIdleTimeout is
	// the idle write deadline; zero means DefaultWriteIdleTimeout.
	MaxArchives          int
	MaxArchivesPerClient int
	WriteIdleTimeout     time.Duration
}

Config configures a Handler.

type Handler

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

Handler serves the REST subset.

func New

func New(cfg Config) *Handler

New builds a Handler.

func (*Handler) ServeHTTP

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

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

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