Documentation
¶
Index ¶
- type Handler
- func (h *Handler) GetPostTypes(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetPublicPostTypes(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetRoles(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetUserFieldsEndpoint(w http.ResponseWriter, r *http.Request)
- func (h *Handler) SetRegistrationEnabled(enabled bool)
- type PostTypeServiceInterface
- type Role
- type RoleCapabilities
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 ¶
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.