api

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 7 Imported by: 1 module, 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

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

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.

Jump to

Keyboard shortcuts

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