Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrProductNotFound = fmt.Errorf("Product not found")
Functions ¶
func AddProduct ¶
func AddProduct(p Product)
func DeleteProduct ¶
DeleteProduct deletes the product with the given id
func ToJSONInterface ¶
ToJSON serializes the given interface into a string based JSON format
func UpdateProduct ¶
UpdateProdict replaces the Product with the given id.
Types ¶
type Product ¶
type Product struct { // the id for this product // // required: true ID int `json:"id"` // the name for this poduct // // required: true // max length: 255 Name string `json:"name" validate:"required"` // the description for this poduct // // required: false // max length: 10000 Description string `json:"description"` // the price for the product // // required: true // min: 0.01 Price float32 `json:"price" validate:"gt=0"` // the SKU for the product // // required: true // pattern: [a-z]+-[a-z]+-[a-z]+ SKU string `json:"sku" validate:"required,sku"` CreatedOn string `json:"-"` UpdatedOn string `json:"-"` DeletedOn string `json:"-"` }
Product defines the structure for an API product. Product also has relevant struct tags for validation and json encoding. swagger:model
func GetProductByID ¶
GetProductByID returns a single product which matches the id from the database. If a product is not found this function returns a ProductNotFound error
Click to show internal directories.
Click to hide internal directories.