internal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package internal implements the workflow-plugin-cms plugin — the CMS engine used by gocodealone-multisite to serve multi-tenant content sites from a single workflow app.

Module types provided:

  • cms.tenant_resolver — Host → tenant_id middleware (V1, V2)
  • cms.static_serve_before_dynamic — static-wins routing (V3)
  • cms.engine — page CRUD + render + dynamic-section substitution + theme resolver
  • analytics.injection — per-tenant Google Analytics injection (delegated to workflow-plugin-analytics when present; V25)

Step types provided:

  • step.cms_render_page — render a CMS page for the resolved tenant
  • step.cms_bundle_activate — atomic-swap a fetched bundle into place

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.0.0"

Version is set at build time via -ldflags.

Functions

func NewPlugin

func NewPlugin() sdk.PluginProvider

NewPlugin returns a new plugin instance.

func WithTenant

func WithTenant(ctx context.Context, info TenantInfo) context.Context

WithTenant returns a context carrying the resolved tenant.

Types

type AdminAPI

type AdminAPI struct {
	ReloadFunc  func() error
	PreviewBase string
	Audit       *audit.Logger
	AuditActor  func(*http.Request) string
	// contains filtered or unexported fields
}

AdminAPI is the HTTP surface for the multisite admin.

Per SPEC §I/T16: tenant CRUD, domain CRUD, page CRUD. Routes are mounted by the host at /api/v1/admin/* (see gocodealone-multisite app.yaml). The host wraps every endpoint with auth + authz middleware; this layer assumes the request is already authenticated.

Tenant scope for page endpoints comes from the URL path (/api/v1/admin/tenants/:id/pages...) — V12 isolation is enforced by passing tenantID as the first arg after ctx into every store call.

ReloadFunc is optional; when set, POST /api/v1/admin/reload invokes it to flush in-memory caches (tenant resolver, page renderer). See SPEC T31.

PreviewBase is the FQDN suffix for auto-provisioned preview subdomains. When non-empty, CreateTenant also creates a `<slug>.<preview_base>` domain row (V18 / T32). Empty disables auto-provision.

func NewAdminAPI

func NewAdminAPI(tenants store.TenantAdminStore, pages store.PageStore) *AdminAPI

NewAdminAPI returns a handler using the given stores. Either store may be the in-memory implementation (default) or a postgres-backed production impl.

func (*AdminAPI) ServeHTTP

func (a *AdminAPI) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches by method + path.

type CMSPlugin

type CMSPlugin struct{}

CMSPlugin implements sdk.PluginProvider.

func (*CMSPlugin) CreateModule

func (p *CMSPlugin) CreateModule(typeName, name string, config map[string]any) (sdk.ModuleInstance, error)

CreateModule creates a module instance of the given type.

func (*CMSPlugin) CreateStep

func (p *CMSPlugin) CreateStep(typeName, name string, config map[string]any) (sdk.StepInstance, error)

CreateStep creates a pipeline step instance of the given type.

func (*CMSPlugin) Manifest

func (p *CMSPlugin) Manifest() sdk.PluginManifest

Manifest returns plugin metadata.

func (*CMSPlugin) ModuleTypes

func (p *CMSPlugin) ModuleTypes() []string

ModuleTypes returns the module types this plugin provides.

func (*CMSPlugin) StepTypes

func (p *CMSPlugin) StepTypes() []string

StepTypes returns the step types this plugin provides.

type TenantInfo

type TenantInfo struct {
	TenantID     int64
	TenantSlug   string
	SubsiteLabel string // empty if no subsite scope
	Kind         string // "vanity" | "preview" | "subdomain"
}

TenantInfo is the resolved tenant + optional subsite for a request.

func TenantFromContext

func TenantFromContext(ctx context.Context) (TenantInfo, bool)

TenantFromContext returns the tenant resolved upstream, or ok=false if none was set (request would not have reached this point through the normal flow).

type TenantStore

type TenantStore interface {
	// Lookup returns the tenant for an exact domain match. ok=false on miss.
	Lookup(ctx context.Context, host string) (TenantInfo, bool)
	// LookupBySlug resolves a preview subdomain pattern (<slug>.<base>).
	LookupBySlug(ctx context.Context, slug string) (TenantInfo, bool)
}

TenantStore looks up tenants by domain. Host wires the production postgres-backed implementation at boot.

Jump to

Keyboard shortcuts

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