posttypesbasic

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 5 Imported by: 2 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.

README

modules/posttypes-basic

Official Lesstruct module: the post + page content types and the post-type registry host.

Layout (module template)

module.go            # kernel.Module + capabilities (single registry-facing file)
api/                 # HTTP handlers + legacy envelope (delivery layer)
domain/              # registry service, entities, validation (moved from internal/domain/posttype)
admin/               # admin-shell manifest (empty: the UI is data-driven)
testutil/            # kernel fixture for module tests

Deliberately absent: store/ and migrations/ — the registry is in-memory, so there is nothing to persist or migrate. If post types ever grow stored state, those directories appear here following the template.

Capabilities

  • ContentTypeProvider — declares post + page (protected) plus custom types (unprotected). The media/comment placeholders stay out: the media and comments modules claim those slugs when they land.
  • RouteProvider — GET /post_types, GET /roles, GET /user_fields (admin-gated via the injected resolver).
  • PublicRouteProvider — GET /post_types (anonymous).
  • AdminExtensionProvider — empty manifest (the admin UI reads the API).

Transfers

GET /roles and GET /user_fields are served here only until the users module lands, which takes them over unchanged.

Documentation

Overview

Package posttypesbasic is the official post + page content-type module.

It hosts the post-type registry (adopted from the composition root, which builds it from config), declares the post and page definitions to the kernel discovery index, and serves the post-type HTTP surface. It carries no database tables and no migrations: the registry is in-memory.

The /roles and /user_fields endpoints are served here only until the users module lands, which takes them over unchanged.

Index

Constants

View Source
const (
	// Name is the registry key for this module.
	Name = "posttypes-basic"

	// Version is the module version reported via Module.Version.
	Version = "0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module is the posttypes-basic kernel module.

func New

func New(opts ...Option) *Module

New builds the module, adopting the composition root's wiring. The handler is built once here so routes serve the same instance the provider reads.

func (*Module) AdminManifest

func (m *Module) AdminManifest() kernel.AdminExtensionManifest

AdminManifest declares this module's admin-shell extensions. Post types surface in the admin UI data-driven (content tabs and the editor dropdown read the post-types API), so the module declares no menu entries, settings sections, or editor extensions.

func (*Module) Init

func (m *Module) Init(_ kernel.Kernel) error

Init wires the module. The handler is already built by New; Init only validates the adopted service is present.

func (*Module) Name

func (m *Module) Name() string

Name returns the registry key.

func (*Module) Optional

func (m *Module) Optional() []string

Optional lists soft dependencies. None: role scoping degrades to allow-all without a resolver by design.

func (*Module) PostTypes

func (m *Module) PostTypes() []kernel.PostTypeDef

PostTypes declares this module's content types to the kernel discovery index: post and page as protected, plus every custom type in the adopted registry unprotected. The media/comment placeholders stay out (see deferredSlugs).

func (*Module) RegisterPublicRoutes

func (m *Module) RegisterPublicRoutes(router chi.Router)

RegisterPublicRoutes mounts the anonymous post-type surface. Core passes the public router (no auth chain).

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(router chi.Router)

RegisterRoutes mounts the authenticated post-type surface. Core passes the protected router (auth pre-chained).

func (*Module) Requires

func (m *Module) Requires() []string

Requires lists hard dependencies. This module has none: it serves every authenticated caller when no resolver is attached.

func (*Module) Service

func (m *Module) Service() *posttype.Service

Service exposes the adopted registry for composition-root wiring (content adapter, importers, templates, role loading). It stays valid for the module's lifetime.

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown releases module resources. There are none beyond memory.

func (*Module) Version

func (m *Module) Version() string

Version returns the module version.

type Option

type Option func(*Module)

Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module with the default registry.

func WithCapabilityResolver

func WithCapabilityResolver(resolve kernel.CapabilityResolver) Option

WithCapabilityResolver attaches the authorizer for role-scoped surfaces. Without one every authenticated caller sees everything (legacy behavior).

func WithCommentsEnabled

func WithCommentsEnabled(enabled bool) Option

WithCommentsEnabled toggles the "comment" sentinel in list surfaces, mirroring the [comments] config block.

func WithRegistrationEnabled

func WithRegistrationEnabled(enabled bool) Option

WithRegistrationEnabled adopts the registration gate consulted for the Commentator role in GetRoles. When unset it defaults to the comments flag, preserving the legacy coupling.

func WithRoles

func WithRoles(roles api.RoleCapabilities) Option

WithRoles attaches the role registry for the roles endpoint. Without one the endpoint answers 404 roles_unavailable (fail closed).

func WithService

func WithService(service *posttype.Service) Option

WithService adopts a config-built registry (composition root). Without it the module seeds its own default registry.

Directories

Path Synopsis
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for post types.
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for post types.
Package testutil provides the kernel fixture module tests run against: an in-memory post-type registry with no external dependencies.
Package testutil provides the kernel fixture module tests run against: an in-memory post-type registry with no external dependencies.

Jump to

Keyboard shortcuts

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