api

package
v0.0.0-...-641ea43 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package api is the Cairn control-plane HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Store store.Store
	Queue provisioning.Queue
	// Resolvers maps each Git host to its OAuth resolver. Multiple hosts may be
	// registered at once — students self-enroll via the resolver for their
	// classroom's host, and operators log in via the LoginHost resolver.
	Resolvers map[adapter.Host]identity.Resolver
	// LoginHost identifies which resolver handles operator login. When empty, the
	// server picks whichever resolver is available (GitHub preferred).
	LoginHost adapter.Host
	// WebDir, if set, is a directory of built dashboard assets (web/dist) served
	// at the root with SPA fallback, so the API and UI ship as one binary.
	WebDir string
	// AuthEnabled gates operator authentication. When false (the default), the
	// management API is open and a synthetic operator is used — convenient for
	// local development, but every deployment should enable it.
	AuthEnabled bool
	// AdminUsers is the allowlist of host usernames permitted to operate this
	// instance (only consulted when AuthEnabled).
	AdminUsers []string
	// CookieSecure sets the Secure flag on the session cookie; enable it behind HTTPS.
	CookieSecure bool
	// GraderConfigured reports whether a grading runner has been wired up. When
	// false, POST /assignments/{id}/grade returns 409 immediately instead of
	// enqueueing jobs that would instantly fail in the worker.
	GraderConfigured bool
	// Adapters is the set of configured host adapters. handleCreateClassroom
	// validates a classroom's host against these so a classroom can only be
	// created for a host Cairn can actually provision against — deriving the
	// allowlist from runtime registration keeps it correct as hosts are added
	// (e.g. both "forgejo" and "gitea" once the Gitea-family adapter is wired).
	// The student API also uses them for RepoWebURL links.
	Adapters map[adapter.Host]adapter.Adapter
	// WebhookSecrets is the per-host secret used to verify incoming push-webhook
	// HMAC signatures. A host with no secret here has its deliveries rejected.
	WebhookSecrets map[adapter.Host]string
}

Options holds the Server's dependencies.

type Server

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

Server routes and serves the control-plane API.

func New

func New(opts Options) *Server

New constructs a Server with routes registered.

func (*Server) ServeHTTP

func (s *Server) 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