api

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package api provides the HTTP server for the stackit-web application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestIDFromContext added in v0.19.0

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext is kept here as a re-export for callers in the api package; handlers in other packages import internal/api/reqid directly.

Types

type AuthConfig added in v0.19.0

type AuthConfig struct {
	Handler      *auth.Handler
	SessionStore auth.Store
}

AuthConfig is the runtime auth setup. SessionStore must outlive the Server's lifetime (close it after Shutdown returns).

type Server

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

Server is the stackit-web HTTP server. Per-repo state (engine, watcher, broadcaster) lives on each registry entry — the server only owns transport-level concerns.

func NewServer

func NewServer(cfg ServerConfig) *Server

NewServer creates a new API server backed by the given registry.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server. The registry's watchers and broadcasters are torn down separately by main.go's defer reg.Close().

func (*Server) Start

func (s *Server) Start() error

Start begins serving HTTP requests. It blocks until the server is stopped.

type ServerConfig

type ServerConfig struct {
	// BindAddr is the host/IP to listen on. Empty means "all interfaces".
	// apps/server picks a safe default (127.0.0.1) and switches to the
	// public-facing form when PORT or STACKIT_PUBLIC is set.
	BindAddr    string
	Port        int
	CORSOrigins []string
	APIPrefixes []string
	StaticFS    fs.FS
	Registry    *registry.Registry

	// Auth bundles the OAuth handler, session store, and surrounding state
	// needed to gate /api/* routes behind GitHub login. When nil the server
	// runs without authentication; that mode is only safe on a private
	// network (localhost dev, tunneled access). apps/server refuses to
	// start unauthenticated when STACKIT_PUBLIC or $PORT are set unless
	// -auth-disabled is passed explicitly.
	Auth *AuthConfig
}

ServerConfig holds configuration for the API server.

Directories

Path Synopsis
Package auth implements GitHub OAuth + session cookies + an allowlist gate so stackit-server can be safely exposed on the public web.
Package auth implements GitHub OAuth + session cookies + an allowlist gate so stackit-server can be safely exposed on the public web.
Package registry holds the set of repositories served by the stackit server, keyed by a stable repoID.
Package registry holds the set of repositories served by the stackit server, keyed by a stable repoID.
Package reqid holds the request-ID context plumbing shared between the middleware that mints the ID (internal/api) and the handlers that want to include it in audit log lines (internal/api/handlers).
Package reqid holds the request-ID context plumbing shared between the middleware that mints the ID (internal/api) and the handlers that want to include it in audit log lines (internal/api/handlers).
Package watcher provides file system monitoring for git ref changes.
Package watcher provides file system monitoring for git ref changes.

Jump to

Keyboard shortcuts

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