Documentation ¶
Index ¶
- func Delay(d time.Duration) func(next http.Handler) http.Handler
- func Run() error
- func WithLatency(l string) option
- type MemoryStore
- type Product
- type Products
- type Property
- type Server
- func (cs *Server) GetCoffee(w http.ResponseWriter, r *http.Request)
- func (cs *Server) GetProduct(w http.ResponseWriter, r *http.Request)
- func (cs *Server) GetProducts(w http.ResponseWriter, r *http.Request)
- func (cs *Server) GetTea(w http.ResponseWriter, r *http.Request)
- func (cs *Server) ListenAndServe() error
- func (cs *Server) Shutdown(ctx context.Context) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithLatency ¶
func WithLatency(l string) option
Types ¶
type MemoryStore ¶
type MemoryStore struct { Products Products // contains filtered or unexported fields }
MemoryStore represents a storage for products in the CoffeeShop.
Use memory store for testing and development. For production use a SQL or NoSQL database.
func (*MemoryStore) GetAll ¶
func (ms *MemoryStore) GetAll() []Product
GetAll returns all products in the store.
func (*MemoryStore) GetCoffee ¶
func (ms *MemoryStore) GetCoffee() []Product
func (*MemoryStore) GetProduct ¶
func (ms *MemoryStore) GetProduct(id string) (Product, error)
func (*MemoryStore) GetTea ¶
func (ms *MemoryStore) GetTea() []Product
type Product ¶
type Product struct { ID string `json:"id"` Type string `json:"type"` Brand string `json:"brand"` Name string `json:"name"` Unit string `json:"unit,omitempty"` Quantity string `json:"quantity,omitempty"` Price string `json:"price,omitempty"` Properties []Property `json:"properties,omitempty"` }
Product represents a product in the inventory.
type Server ¶
func (*Server) GetProduct ¶
func (cs *Server) GetProduct(w http.ResponseWriter, r *http.Request)
func (*Server) GetProducts ¶
func (cs *Server) GetProducts(w http.ResponseWriter, r *http.Request)
func (*Server) ListenAndServe ¶
Click to show internal directories.
Click to hide internal directories.