playgroundserver

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package playgroundserver is the SPL browser playground's HTTP server, started by cmd/interpreter's --playground mode (see runPlayground in cmd/interpreter/main.go). Variant exists so the small pieces that once differed between separate lightweight/full playground binaries (linked builtins, example scripts, extra untrusted-profile capabilities) stay expressible as a single struct rather than duplicated main.go bodies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(v Variant)

Run boots the playground HTTP server for the given Variant and blocks until it exits (on signal, via graceful shutdown) or fails to start (via os.Exit, matching the behavior main() had before this package existed).

Types

type Config

type Config struct {
	Addr                string
	AuthSecret          string
	ExecutionProfile    string
	ReadTimeout         time.Duration
	WriteTimeout        time.Duration
	IdleTimeout         time.Duration
	ShutdownTimeout     time.Duration
	MaxBodyBytes        int64
	RateLimit           int
	RateWindow          time.Duration
	RateCleanup         time.Duration
	TrustProxy          bool
	CookieSecure        bool
	SessionTTL          time.Duration
	EvalMaxDepth        int
	EvalMaxSteps        int64
	EvalMaxHeapMB       int64
	EvalTimeoutMS       int64
	RenderAllowURLs     bool
	RenderAllowURLHosts []string
	RenderMode          string
	RenderMaxBytes      int64
	// DevMode is an explicit opt-out of the production-safety guard below.
	// When true, the server is allowed to bind to a non-loopback address
	// without an authentication secret and/or secure cookies configured -
	// intended only for local development, CI, and tests. It defaults to
	// false, so production-style deployments (bound to a non-loopback
	// address) must either configure auth + secure cookies or explicitly
	// set PLAYGROUND_DEV_MODE=true to acknowledge the reduced security.
	DevMode bool
}

Config is the playground's env/CLI-driven runtime configuration, used by cmd/interpreter's --playground mode. It lives here rather than in main.go so it stays testable independent of process startup.

type Variant

type Variant struct {
	// Name labels the variant in logs (e.g. "full").
	Name string
	// ExtraCapabilities are additional untrusted-profile capabilities
	// granted on top of the shared baseline (filesystem_read, async,
	// scheduler, server) - e.g. cmd/interpreter's --playground mode adds
	// CapabilityDB and CapabilityNetwork.
	ExtraCapabilities []string
	// ExampleOverrides replaces specific keys in the shared base example
	// set (see examples.go) - used for scripts whose content depends on
	// which builtins are linked (image-values, query-builder).
	ExampleOverrides map[string]string
	// ExtraExamples adds example keys unique to this variant (e.g.
	// "pdf-tools", only meaningful when builtins/pdf is linked).
	ExtraExamples map[string]string
	// IDERunner configures the Projects-mode process manager (which
	// interpreter binary to build/run projects with, and the default
	// scaffold kind) - see pkg/ide.RunnerConfig.
	IDERunner ide.RunnerConfig
}

Variant is the small set of parameters a --playground caller supplies. Everything else - config loading, auth, rate limiting, metrics, HTTP handlers, middleware, and static asset serving - lives in this package.

Jump to

Keyboard shortcuts

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