Documentation
¶
Overview ¶
Package media is the official media-library module: uploads, the media library, AI image generation, and thumbnail variants.
Index ¶
- Constants
- type Module
- func (m *Module) AdminManifest() kernel.AdminExtensionManifest
- func (m *Module) AgentHandler() *agent.MediaHandler
- func (m *Module) BrowserHandler() *api.MediaHandler
- func (m *Module) Init(_ kernel.Kernel) error
- func (m *Module) Migrations() fs.FS
- func (m *Module) Name() string
- func (m *Module) Optional() []string
- func (m *Module) Requires() []string
- func (m *Module) Service() *mediadomain.Service
- func (m *Module) Shutdown() error
- func (m *Module) Version() string
- type Option
Constants ¶
const ( // Name is the registry key for this module. Name = "media" // 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 media kernel module.
func New ¶
New builds the module, adopting the composition root's wiring. Both realm handlers are built once here so routes serve the same instances.
func (*Module) AdminManifest ¶
func (m *Module) AdminManifest() kernel.AdminExtensionManifest
AdminManifest declares this module's admin-shell extensions: the media library navigation entry.
func (*Module) AgentHandler ¶
func (m *Module) AgentHandler() *agent.MediaHandler
AgentHandler exposes the Bearer-realm handler for core mounting, alongside the browser handler for the same per-route-limit reason.
func (*Module) BrowserHandler ¶
func (m *Module) BrowserHandler() *api.MediaHandler
BrowserHandler exposes the JWT/CSRF-realm handler for core mounting. Core mounts it explicitly (rather than via RouteProvider) because the media surface spans three body-limit groups plus the dual-auth dispatch — a single RegisterRoutes call cannot express per-route body limits.
func (*Module) Init ¶
Init wires the module. The handlers are already built by New; Init only validates presence. Migration execution is core-driven (it needs the live *sql.DB, which modules never touch directly).
func (*Module) Migrations ¶
Migrations returns the embedded migration filesystem, laid out per driver ({sqlite,postgresql,mysql}/NNN_name.{up,down}.sql). The core runner tracks each module in its own schema_migrations_<module> table.
func (*Module) Requires ¶
Requires lists hard dependencies. Media references users loosely (owner IDs without foreign-key enforcement), so nothing is required.
func (*Module) Service ¶
func (m *Module) Service() *mediadomain.Service
Service exposes the adopted domain service for composition-root wiring (importers, text generation, templates). It stays valid for the module's lifetime.
type Option ¶
type Option func(*Module)
Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module that serves nothing (handlers built over nil dependencies must not be invoked).
func WithAgentRoles ¶
func WithAgentRoles(roles agent.RoleCapabilities) Option
WithAgentRoles attaches the role registry for the agent upload gate. It is a separate option (rather than sharing WithRoles) because the two api packages own their seams independently; core satisfies both with one adapter.
func WithImageGeneration ¶
func WithImageGeneration(service mediadomain.ImageGenerationService) Option
WithImageGeneration adopts the AI image provider (composition root, nil when unconfigured). Without one the generate endpoint answers 503 not_configured (fail closed).
func WithLogger ¶
WithLogger attaches the module logger. Without one handler failures are dropped (discard sink).
func WithRoles ¶
func WithRoles(roles api.RoleCapabilities) Option
WithRoles attaches the role registry for the browser upload/generate/delete gates. Without one every authenticated caller may manage media (the legacy behavior).
func WithService ¶
func WithService(service *mediadomain.Service) Option
WithService adopts the media domain service (composition root). The same instance backs the browser and agent handlers so hashing, dedup, WebP conversion, and thumbnail variants run identically in both realms.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for media.
|
Package admin owns this module's admin-shell manifest: the declarative UI the single admin SPA renders for media. |
|
Package store is the single-source media repository: one implementation against *sql.DB plus a kernel Dialect, replacing the three per-driver copies.
|
Package store is the single-source media repository: one implementation against *sql.DB plus a kernel Dialect, replacing the three per-driver copies. |
|
Package testutil provides the kernel fixture module tests run against.
|
Package testutil provides the kernel fixture module tests run against. |