{"modulePath":"github.com/GoCodeAlone/workflow-plugin-cms","version":"v0.1.10","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package host\n\nPackage host wires the workflow-plugin-cms components into a single http.Handler suitable for a standalone CMS host binary.\n\nThe CMS plugin still ships as an external gRPC plugin (cmd/), but for standalone host deployments the engine runs in-process — this package exposes the same component set without the gRPC boundary.\n\nPer CMS host SPEC.md §I and T13/T14/T16/T28/T31/T32.\n\n## Types\n\n```go\ntype Config struct {\n\t// PreviewSubdomainBase is the FQDN suffix for preview subdomains\n\t// (e.g. \"preview.gocodealone.com\"). Empty disables preview-fallback\n\t// in the tenant resolver AND disables auto-provision of preview\n\t// domain rows on tenant create.\n\tPreviewSubdomainBase string\n\n\t// BundleRoot is the directory the static-serve middleware walks to\n\t// find \u003ctenant\u003e/current/\u003cpath\u003e. Required.\n\tBundleRoot string\n\n\t// HMACSecret signs ingest webhooks (SPEC V8). Required for the\n\t// ingest endpoint to function; if empty, the endpoint returns 503.\n\tHMACSecret string\n\n\t// AdminHost, when set, moves the admin UI to https://\u003cAdminHost\u003e/\n\t// and requires all admin API/media/UI requests to use that host.\n\t// This avoids exposing admin under public tenant paths such as\n\t// /admin on the marketing site.\n\tAdminHost string\n\n\t// AdminAuth gates admin UI/API/media requests. Production should\n\t// wire this to workflow-plugin-auth session/JWT validation. When\n\t// AdminHost is set and AdminAuth is nil, admin requests fail closed.\n\tAdminAuth func(*http.Request) bool\n\n\t// AdminTenantAccess adds membership enforcement after role authorization.\n\t// Hosts with tenant editors must supply it; nil preserves legacy operator-only wiring.\n\tAdminTenantAccess func(*http.Request, int64) bool\n\t// AdminPlatformAccess is mandatory for tenant creation, domain reads/writes\n\t// and global cache reload. Hosts must enforce durable platform authority.\n\tAdminPlatformAccess func(*http.Request) bool\n\n\t// OnIngest is called with the verified payload. Production wires\n\t// this to a Fetcher; tests typically pass a no-op.\n\tOnIngest func(bundle.IngestPayload) error\n\n\t// Stores. Defaults are in-memory; production passes postgres-backed\n\t// implementations.\n\tTenantsAdmin store.TenantAdminStore\n\tPages        store.PageStore\n\n\t// PageTemplates maps CMS template IDs to HTML shells containing\n\t// \u003c!--cms:body--\u003e. Missing/empty template IDs render the page body only.\n\tPageTemplates map[string]string\n\n\t// TenantResolverStore is the read-side tenant lookup interface used\n\t// by the resolver middleware. If both this and TenantsAdmin are\n\t// nil, a memory-backed store is created and shared between them\n\t// via a thin adapter.\n\tTenantResolverStore TenantResolverStore\n\n\t// AnalyticsConfigForTenant returns the per-tenant analytics config\n\t// (gtag measurement_id + anonymize_ip). Nil disables injection.\n\tAnalyticsConfigForTenant func(tenantID int64) analytics.TenantConfig\n\n\t// HealthCheck reports liveness (DB ping, etc.). Nil → always OK.\n\tHealthCheck func(ctx context.Context) error\n\n\t// MediaBackend persists tenant-scoped uploads. Nil disables the\n\t// upload endpoint (returns 503).\n\tMediaBackend media.Backend\n\n\t// AuditSignKey signs audit-chain entries. Empty disables audit\n\t// recording. Audit entries are emitted for tenant + page mutations.\n\tAuditSignKey string\n\n\t// AuditSink persists audit-chain entries. Nil uses an in-memory sink.\n\t// Ignored when AuditSignKey is empty.\n\tAuditSink audit.Sink\n\n\t// AuditActor returns the actor recorded for admin audit entries.\n\t// Empty return values fall back to \"admin\".\n\tAuditActor func(*http.Request) string\n}\n```\nConfig controls the host wiring.\n\n```go\ntype Server struct {\n\t// contains filtered or unexported fields\n}\n```\nServer is the assembled multisite host.\n\n```go\nfunc New(cfg Config) *Server\n```\nNew builds a Server. Fills in memory-backed defaults for nil stores.\n\n```go\nfunc (s *Server) AdminAPI() *internal.AdminAPI\n```\nAdminAPI returns the underlying admin handler (for tests + advanced wiring).\n\n```go\nfunc (s *Server) Audit() *audit.Logger\n```\nAudit returns the audit Logger if configured. May be nil.\n\n```go\nfunc (s *Server) EmitMetrics(_ context.Context, recorder telemetry.MetricRecorder) error\n```\n\n```go\nfunc (s *Server) ResolveTenant(ctx context.Context, host string) (TenantInfo, bool)\n```\nResolveTenant uses authoritative domain/tenant lookup. Host-policy decisions and public rendering share this lookup; an indefinitely cached mapping could serve the wrong tenant after a domain move. Resolver stores may optimize reads.\n\n```go\nfunc (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\nServeHTTP routes a single request. Order of resolution:\n\n 1. /healthz (always served, even without a Host header match)\n 2. /api/v1/admin/\\* — handed to AdminAPI (+ media upload subroute)\n 3. /api/v1/ingest/release — handed to IngestHandler (HMAC)\n 4. Everything else → tenant resolve → static-serve → 404 if neither\n\nEvery request increments the per-tenant request counter (V30) keyed on the resolved tenant slug (or \"\\_unresolved\" for admin/system routes).\n\n```go\ntype TenantInfo = internal.TenantInfo\n```\nTenantInfo mirrors internal.TenantInfo so callers don't need to import internal.\n\n```go\ntype TenantResolverStore interface {\n\tLookup(ctx context.Context, host string) (TenantInfo, bool)\n\tLookupBySlug(ctx context.Context, slug string) (TenantInfo, bool)\n}\n```\nTenantResolverStore is the read-side tenant lookup interface — it is satisfied by \\`internal.TenantStore\\` (the resolver expects this shape).\n\n","path":"github.com/GoCodeAlone/workflow-plugin-cms/host","name":"host","synopsis":"Package host wires the workflow-plugin-cms components into a single http.Handler suitable for a standalone CMS host binary.","isRedistributable":true}
