api

package
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: 8 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler handles post type HTTP requests.

func New

func New(
	postTypeService PostTypeServiceInterface,
	commentsEnabled bool,
	resolve kernel.CapabilityResolver,
	roles RoleCapabilities,
) *Handler

New builds a Handler. A nil resolver disables role scoping (legacy allow-all); nil roles fail the roles endpoint closed with 404.

func (*Handler) GetPostTypes

func (h *Handler) GetPostTypes(w http.ResponseWriter, r *http.Request)

GetPostTypes returns all registered post types (including hidden ones, which carry their hidden flag so the admin UI can filter its surfaces). With a resolver attached, the list is scoped to the caller's manageable types: a config-restricted role (e.g. a journalist managing only "article") only sees the types it may actually use; admins always see everything.

func (*Handler) GetPublicPostTypes

func (h *Handler) GetPublicPostTypes(w http.ResponseWriter, r *http.Request)

GetPublicPostTypes returns visible post types without requiring authentication. Hidden types are excluded — public consumers must never see them.

func (*Handler) GetRoles

func (h *Handler) GetRoles(w http.ResponseWriter, r *http.Request)

GetRoles returns the registered roles (the assignable list the admin user management UI needs) plus the caller's own capabilities (what the content editor and navigation should surface). Requires roles; when the module was built without them it returns 404, mirroring the fail-closed stance of the config-driven role feature. Served here until the users module takes it over. The Commentator entry is filtered on the same predicate the users module gates admin creation with (comments and registration both enabled).

func (*Handler) GetUserFieldsEndpoint

func (h *Handler) GetUserFieldsEndpoint(w http.ResponseWriter, r *http.Request)

GetUserFieldsEndpoint returns user field schemas (custom and system). It is admin-gated via the capability resolver, matching the core AdminOnly chain it replaces (403 INSUFFICIENT_PERMISSIONS with the identical message). Served here until the users module takes it over.

func (*Handler) SetRegistrationEnabled

func (h *Handler) SetRegistrationEnabled(enabled bool)

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

type PostTypeServiceInterface

type PostTypeServiceInterface interface {
	GetAll() []posttype.PostType
	GetBySlug(slug string) (posttype.PostType, error)
	Register(pt posttype.PostType) error
	GetUserFields() []customfield.FieldSchema
	GetUserSystemFields() []customfield.FieldSchema
}

PostTypeServiceInterface defines the interface for post type service

type Role

type Role struct {
	Name      string
	PostTypes []string
	AllTypes  bool
	Publish   bool
	Media     bool
	Comments  bool
	IsAdmin   bool
}

Role is the assignable-role shape the roles endpoint serializes. It mirrors the users module's role record; core adapts *role.Service to the RoleCapabilities interface below until the users module lands.

type RoleCapabilities

type RoleCapabilities interface {
	IsAdmin(name string) bool
	ManageablePostTypes(name string, allSlugs []string) []string
	CanPublish(name string) bool
	CanMedia(name string) bool
	CanComment(name string) bool
	GetAll() []Role
}

RoleCapabilities is the narrow role-registry seam this handler depends on. Core satisfies it with an adapter over *role.Service (which cannot be imported here); the users module implements it natively when it lands.

Jump to

Keyboard shortcuts

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