Documentation
¶
Overview ¶
Package config defines the shared, user-facing types used inside a project's gothic.config.go file: the typed environment-value builders (Env, SSMParam, SecretsManager) and the GothicContext passed to lifecycle hooks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSProvider ¶ added in v1.1.0
type AWSProvider struct {
ServerMemory int
ServerTimeout int
Region string
Profile string
Stages map[string]Stage
// CDN tunes how the CloudFront distribution caches and forwards the dynamic
// (server) requests: which query params, cookies, and request headers reach your
// app and vary its cache. Its zero value keeps ALL query params (so ?lang=PT and
// ?lang=ENG render and cache independently) and forwards no cookies or headers —
// the safe default for a Lambda Function URL behind Origin Access Control. Set
// each field with the gothic.Allow* builders. See CDNConfig (config/cdn.go).
CDN CDNConfig
}
AWSProvider holds the AWS-specific deploy settings and per-stage configuration.
type AllowRule ¶ added in v1.2.0
type AllowRule struct {
// contains filtered or unexported fields
}
AllowRule is an opaque rule for one class of request values (query params, cookies, or headers) in a CDNConfig. Build it only with AllowAll / AllowNone / Allow / AllowAllExcept; its zero value means "unset" (use the field default).
func Allow ¶ added in v1.2.0
Allow includes only the named values (a whitelist). Pass at least one name.
func AllowAll ¶ added in v1.2.0
func AllowAll() AllowRule
AllowAll includes every value of the class in the cache key and forwards them to the origin.
func AllowAllExcept ¶ added in v1.2.0
AllowAllExcept includes every value except the named ones. Pass at least one name. Not valid for headers.
func AllowNone ¶ added in v1.2.0
func AllowNone() AllowRule
AllowNone excludes the class entirely — nothing is forwarded or cached on.
func (AllowRule) Behavior ¶ added in v1.2.0
Behavior returns the CloudFront cache-policy behavior string for this rule ("all", "none", "whitelist", or "allExcept"), or "" when the rule is unset (the caller should substitute the field's default). It exists for the deploy generator; user code never needs it.
type CDNConfig ¶ added in v1.2.0
type CDNConfig struct {
// QueryParams controls query-string participation. Default: AllowAll — every
// query param is forwarded and part of the cache key, so ?lang=PT and ?lang=ENG
// render and cache independently.
QueryParams AllowRule
// Cookies controls cookie participation. Default: AllowNone.
Cookies AllowRule
// Headers controls request-header participation. Default: AllowNone.
//
// Headers accept only AllowNone or Allow (a whitelist) — AllowAll / AllowAllExcept
// are rejected at deploy time (a CloudFront cache-policy limit). Never Allow the
// "Host" or "Authorization" header for the server behavior: CloudFront signs the
// Lambda Function URL (SigV4, via Origin Access Control) against the function
// URL's own host, so forwarding either header breaks the signature (HTTP 403).
Headers AllowRule
}
CDNConfig configures how the CloudFront distribution treats the dynamic (server) requests it forwards to your app: which query params, cookies, and request headers are forwarded to the origin AND folded into the cache key (so two requests that differ only in an allowed value cache separately).
Each field is set with the gothic.Allow* builders — you never construct an AllowRule directly:
CDN: gothic.CDNConfig{
QueryParams: gothic.AllowAll(), // the default
Cookies: gothic.Allow("session", "cart"), // only these
Headers: gothic.Allow("CloudFront-Viewer-Country"),
}
The zero value of a field applies Gothic's per-field default: AllowAll for QueryParams, AllowNone for Cookies and Headers. So an omitted CDN block keeps every query param in the cache key and forwards no cookies or headers.
type CacheConfig ¶
type CacheConfig struct {
RedisURL string
RedisPassword string
RedisTLS bool
CacheFilesPath string
Compression bool
CompressionMethod CompressionMethod
}
CacheConfig carries backend-specific cache settings.
type CacheType ¶
type CacheType int
CacheType selects a cache backend.
const ( // CACHE_CONTROL_HEADERS is the default — production behavior emitting // Cache-Control headers for a CDN rather than storing responses. CACHE_CONTROL_HEADERS CacheType = iota // IN_MEMORY caches responses in a Go in-memory map. IN_MEMORY // REDIS caches responses in Redis (see CacheConfig.RedisURL). REDIS // LOCAL_FILES caches responses on the local filesystem. LOCAL_FILES )
type CompressionMethod ¶
type CompressionMethod int
CompressionMethod selects a compression algorithm for cached/served payloads.
const ( // GZIP is the default compression method. GZIP CompressionMethod = iota // BROTLI uses Brotli compression. BROTLI )
type Config ¶
type Config struct {
ProjectName string
TofuBinaryPath string
DockerfilePath string
WasmBinary string
TailwindBinary string
OptimizeImages OptimizeImagesConfig
// Runtime is the routing/caching configuration the generated main.go hands to
// gothicServer.Middleware. It is read at runtime (not by the CLI's config
// parser), and its zero value is the default behavior, so it may be omitted.
Runtime RuntimeConfig
Deploy *DeployConfig
}
Config is the user-facing configuration type declared in a project's gothic.config.go file. It mirrors the internal cli.Config that the AST parser produces, but lives here so user projects can reference it via the public gothicframework/core/config package without importing CLI internals.
GoModuleName is intentionally absent: it is read from go.mod at runtime.
type DeployConfig ¶
type DeployConfig struct {
// Provider chooses which cloud to deploy to. Defaults to AWS.
Provider Provider
// Providers holds the per-provider deploy settings.
Providers Providers
}
DeployConfig selects a deploy provider and holds the per-provider settings. The AWS-specific settings (memory, timeout, region, profile, stages) now live under Providers.AWS so additional providers can be added under Providers later without reshaping the top-level Deploy block.
type EnvValue ¶
type EnvValue struct {
Source EnvSource
Value string
// JSONKey, when non-empty, selects a single field out of a JSON-encoded
// secret/parameter at deploy time (jsondecode(...)["JSONKey"]). Set via .Get.
JSONKey string
}
EnvValue is an opaque typed wrapper around a runtime env var. Users construct these via the builder functions below; the AST parser identifies each builder by its call-expression function name.
func SecretsManager ¶
SecretsManager declares an environment value sourced from a Secrets Manager path/ARN.
func (EnvValue) Get ¶
Get selects a single field from a JSON-encoded secret or parameter. AWS Secrets Manager secrets are commonly stored as a JSON object (e.g. {"secret-key":"..."}); gothic.SecretsManager("/myapp/dev/api-key").Get("secret-key") pulls just that key at deploy time via Terraform's jsondecode, so the env var receives the value rather than the whole JSON blob. It also works on JSON-valued SSMParam entries.
type GothicContext ¶
type GothicContext struct {
Stage string
ProjectName string
Suffix string
Region string
Env map[string]EnvValue
Outputs map[string]string
}
GothicContext is injected into BeforeDeploy / AfterDeploy lifecycle hooks.
type OptimizeImagesConfig ¶
type OptimizeImagesConfig struct {
// LowResolutionRate is the percentage (of the original width/height) used for
// the small blurred placeholder variant. Defaults to 20 when <= 0.
LowResolutionRate int
// Quality is the encode quality (1–100) applied to the full-size "original"
// variant for lossy formats (JPEG and WebP). Lower means a smaller file. It
// exists to stop `gothic optimize-images` from emitting a near-lossless
// original that balloons a detailed image to several MB. Defaults to 80 when
// <= 0; values are clamped to [1,100]. It does not affect PNG (lossless).
Quality int
}
OptimizeImagesConfig controls image optimization defaults.
type Provider ¶ added in v1.1.0
type Provider int
Provider selects which cloud the stack deploys to. v3 ships AWS only; GCP and Azure are reserved for later without changing the config shape.
type Providers ¶ added in v1.1.0
type Providers struct {
AWS AWSProvider
}
Providers groups the per-provider deploy settings. Only AWS exists in v3; future providers (e.g. GCP, Azure) are added here as additional value fields.
type RuntimeConfig ¶
type RuntimeConfig struct {
// CacheStrategy selects the production cache backend.
CacheStrategy CacheType
// LocalDevelopmentCache selects the dev (hot-reload) cache backend.
LocalDevelopmentCache CacheType
// ServeStaticFiles controls when /public/* is served from disk.
ServeStaticFiles StaticFilesMode
// CacheConfig provides backend-specific settings (Redis URL, file path, ...).
CacheConfig *CacheConfig
}
RuntimeConfig is the runtime routing/caching configuration for the server. Its zero value is the sensible default (CACHE_CONTROL_HEADERS in production, in-memory in dev, static files served only under hot reload), so a project may omit the Runtime field entirely.
type Stage ¶
type Stage struct {
HostedZoneId EnvValue
CustomDomain EnvValue
CertificateArn EnvValue
WafArn EnvValue
ENV map[string]EnvValue
}
Stage is the per-stage configuration declared inside Deploy.Providers.AWS.Stages.
HostedZoneId, CustomDomain, CertificateArn and WafArn are source-aware EnvValues (built with gothic.Env / gothic.SSMParam / gothic.SecretsManager) exactly like ENV entries, so a domain or an ARN can be pulled from SSM Parameter Store or Secrets Manager at deploy time instead of being committed in plain text. Use gothic.Env("literal") for a plain value.
type StaticFilesMode ¶
type StaticFilesMode int
StaticFilesMode controls where /public/* assets are served from.
const ( // CDN (default): the app does not serve /public/* in production — your CDN / // object store does (on AWS that's CloudFront + S3; on other platforms, the // equivalent). The app registers no /public/* handler outside of development, // where it still serves from disk so hot reload works. CDN StaticFilesMode = iota // DISK: the app serves /public/* from the local ./public folder in every // environment (the public/ folder ships alongside the server binary). DISK // EMBEDDED bakes ./public into the binary via go:embed and serves /public/* // from that embed.FS in non-dev envs — a single self-contained binary with no // sidecar public/ folder (intended for self-hosted container/VM deploys). In // dev, files are still served fresh from disk regardless of this mode. EMBEDDED )