Documentation
¶
Overview ¶
Package cart is the official commerce cart module: guest-first, server-side carts with live catalog pricing. Carts are keyed by opaque bearer tokens and served on the public router; the module carries no admin surface and no config of its own.
Index ¶
- Constants
- type Module
- 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) RegisterPublicRoutes(router chi.Router)
- func (m *Module) Requires() []string
- func (m *Module) Shutdown() error
- func (m *Module) Version() string
- type Option
Constants ¶
const ( // Name is the registry key for this module. Name = "cart" // 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 cart kernel module.
func New ¶
New builds the module and constructs the handler once, so every endpoint shares the adopted service.
func (*Module) Init ¶
Init wires the module. The handler is 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 subdirectory (the core migration runner selects via Driver.MigrationDir).
func (*Module) RegisterPublicRoutes ¶
RegisterPublicRoutes mounts the cart surface on the public router (rate-limited, no auth chain): token minting, cart reads, line management, and cart deletion.
func (*Module) Requires ¶
Requires lists hard dependencies. Carts price from the catalog: the module resolves sellable lines through the catalog service it adopts, so disabling catalog cascades the cart off the registry.
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 WithCurrency ¶
WithCurrency sets the display currency for cart payloads, adopted from the catalog configuration. Empty renders payloads without a currency.
func WithLogger ¶
WithLogger attaches the module logger. Without one handler failures are dropped (discard sink).
func WithService ¶
func WithService(service *cartdomain.Service) Option
WithService adopts the cart domain service (composition root). The same instance backs every endpoint so token resolution and totals run identically across the surface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package api hosts the cart module's public HTTP surface: token minting, cart reads, line management, and cart deletion.
|
Package api hosts the cart module's public HTTP surface: token minting, cart reads, line management, and cart deletion. |
|
Package cart is the official commerce cart module: guest-first, server-side carts with live catalog pricing.
|
Package cart is the official commerce cart module: guest-first, server-side carts with live catalog pricing. |
|
Package store is the single-source cart repository: one implementation against *sql.DB plus a kernel Dialect, following the comments/media store pattern.
|
Package store is the single-source cart repository: one implementation against *sql.DB plus a kernel Dialect, following the comments/media store pattern. |
|
Package testutil provides the kernel fixture module tests run against.
|
Package testutil provides the kernel fixture module tests run against. |