Documentation
¶
Overview ¶
Package endpoints used to setup the endpoints logic
Package endpoints used to setup the endpoints logic ¶
Package endpoints used to setup the endpoints logic ¶
Package endpoints used to setup the endpoints logic ¶
Package endpoints used to setup the endpoints logic
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CartEndpoint ¶
type CartEndpoint struct {
Database map[int]database.Product
DiscountServiceAddress string `default:":50051"`
DiscountServiceTimeout int `default:"1"`
BlackFriday string `default:""`
}
CartEndpoint struct that represents the CardEndpoints envvars and Database
func (CartEndpoint) Post ¶
func (cart CartEndpoint) Post(w http.ResponseWriter, r *http.Request)
Post Method that handle the Post Request and Send the Response
type CartRequest ¶
CartRequest struct to Represent each Product Request from the Cart API
type CartRequests ¶
type CartRequests struct {
CartRequest []CartRequest `json:"products"`
}
CartRequests struct the reprents a list of Product Request from the Cart API
type CartResponse ¶
type CartResponse struct {
TotalAmount int `json:"total_amount"`
TotalAmountWithDiscount int `json:"total_amount_with_discount"`
TotalDiscount int `json:"total_discount"`
Products []ResponseProduct `json:"products"`
}
CartResponse struct to represent a Response from the Cart API
func (CartResponse) JSON ¶
func (c CartResponse) JSON() string
JSON transforms the Response into a JSON
type Endpoint ¶
type Endpoint interface {
Post(w http.ResponseWriter, r *http.Request)
}
Endpoint is the default interface used to configure all the possible handlers that implement the Post method
func NewCartEndpoint ¶
func NewCartEndpoint(databasePath string, discountHost string, discountPort string, discountTimeout string, blackFriday string) Endpoint
NewCartEndpoint initialize the Endpoint, setting the envvars inside the struct or its default values For each parameters, its checked if its empty, in case true we use the default value
type ResponseProduct ¶
type ResponseProduct struct {
ID int `json:"id"`
Quantity int `json:"quantity"`
UnitAmount int `json:"unit_amount"`
TotalAmount int `json:"total_amount"`
Discount int `json:"discount"`
IsGift bool `json:"is_gift"`
}
ResponseProduct struct to represent the Product inside the response from the Cart API