state

package
v0.0.0-...-cfb44c8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decoder

func Decoder(res *http.Response, s interface{}) (err error)

Decoder decodes response body to s

func Get

func Get(url string) (*http.Response, error)

Get retrieve url and return response. If Get encounters an error, it will log and return the error.

func Patch

func Patch(url string, payload interface{}) (*http.Response, error)

Patch marshals the payload and send an HTTP Patch request with the payload and return the response. If Patch encounters an error, it will log and return the error.

func Post

func Post(url string, contentType string, payload interface{}) (*http.Response, error)

Post marshals the payload and send an HTTP POST request with the payload and return the response. If Post encounters an error, it will log and return the error.

Types

type CartAPI

type CartAPI struct {
	Cart []memstore.Taco
	// contains filtered or unexported fields
}

CartAPI holds API calls for Cart items

func LoadCartAPI

func LoadCartAPI() *CartAPI

LoadCartAPI returns a new instance of CartAPI

func (*CartAPI) DeleteCartItem

func (c *CartAPI) DeleteCartItem(payload []memstore.Taco) error

DeleteCartItem deletes cart item

func (*CartAPI) GetCart

func (c *CartAPI) GetCart() ([]memstore.Taco, bool, error)

GetCart fetches cart items and uses singleflight to avoid multiple requests. please check that top-nav.vugu and cart.vugu call GetCart and ask for the same data in their initialization. see: https://pkg.go.dev/golang.org/x/sync/singleflight

func (*CartAPI) GetCartTotal

func (c *CartAPI) GetCartTotal() string

GetCartTotal calculates sum of cart items

func (*CartAPI) PostCartItem

func (c *CartAPI) PostCartItem(payload memstore.Taco) error

PostCartItem creates a cart item

type CartAPIRef

type CartAPIRef struct {
	*CartAPI
}

CartAPIRef ref for wiring

func (*CartAPIRef) CartAPISet

func (r *CartAPIRef) CartAPISet(v *CartAPI)

CartAPISet setter for wiring

type CartAPISetter

type CartAPISetter interface {
	CartAPISet(v *CartAPI)
}

CartAPISetter interface for wiring

type TacoListAPI

type TacoListAPI struct {
	TacoList []memstore.Taco
	// contains filtered or unexported fields
}

TacoListAPI holds API calls for Taco List

func LoadTacoListAPI

func LoadTacoListAPI() *TacoListAPI

LoadTacoListAPI returns a new instance of TacoListAPI

func (*TacoListAPI) GetTacoList

func (c *TacoListAPI) GetTacoList() ([]memstore.Taco, bool, error)

GetTacoList fetches taco list

type TacoListAPIRef

type TacoListAPIRef struct {
	*TacoListAPI
}

TacoListAPIRef ref for wiring

func (*TacoListAPIRef) TacoListAPISet

func (r *TacoListAPIRef) TacoListAPISet(v *TacoListAPI)

TacoListAPISet setter for wiring

type TacoListAPISetter

type TacoListAPISetter interface {
	TacoListAPISet(v *TacoListAPI)
}

TacoListAPISetter interface for wiring

Jump to

Keyboard shortcuts

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