Documentation
¶
Overview ¶
Package api hosts the cart module's public HTTP surface: token minting, cart reads, line management, and cart deletion. Everything writes through kernel/httpx — this is a new surface with no legacy envelope contract.
Index ¶
- type Handler
- func (h *Handler) AddItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateCart(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteCart(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetCart(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RemoveItem(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateItem(w http.ResponseWriter, r *http.Request)
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 serves the public cart surface; New builds it once over the adopted service and the display currency for totals payloads.
func New ¶
func New(service *cartdomain.Service, currency string) *Handler
New builds the handler over the adopted service and display currency.
func (*Handler) AddItem ¶
func (h *Handler) AddItem(w http.ResponseWriter, r *http.Request)
AddItem handles POST /cart/items: resolves the sellable line and merges it into the cart.
func (*Handler) CreateCart ¶
func (h *Handler) CreateCart(w http.ResponseWriter, r *http.Request)
CreateCart handles POST /cart: mints a token and an empty cart. The token rides the response body and the X-Cart-Token header; clients present it on every subsequent cart call.
func (*Handler) DeleteCart ¶
func (h *Handler) DeleteCart(w http.ResponseWriter, r *http.Request)
DeleteCart handles DELETE /cart: empties and removes the cart. The token cannot be reused afterwards.
func (*Handler) GetCart ¶
func (h *Handler) GetCart(w http.ResponseWriter, r *http.Request)
GetCart handles GET /cart: the live-priced cart for the presented token.
func (*Handler) RemoveItem ¶
func (h *Handler) RemoveItem(w http.ResponseWriter, r *http.Request)
RemoveItem handles DELETE /cart/items/{itemId}: drops one line.
func (*Handler) UpdateItem ¶
func (h *Handler) UpdateItem(w http.ResponseWriter, r *http.Request)
UpdateItem handles PATCH /cart/items/{itemId}: replaces a line quantity.