Archived
1
0
Fork 0

Add HTTP API

Add `-api` mode to start the HTTP API with the following routes:
- /health
- /shops
- /shops/:id
- /products
- /products/:id

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-03-25 18:00:29 +01:00
commit 17a88265c6
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
7 changed files with 200 additions and 3 deletions

View file

@ -12,8 +12,8 @@ type Product struct {
Price float64 `gorm:"not null" json:"price"`
PriceCurrency string `gorm:"not null" json:"price_currency"`
Available bool `gorm:"not null;default:false" json:"available"`
ShopID uint
Shop Shop
ShopID uint `json:"shop_id"`
Shop Shop `json:"shop"`
}
// Equal compares a database product to another product
@ -41,5 +41,5 @@ func (p *Product) ToMerge(o *Product) bool {
// Shop represents a retailer website
type Shop struct {
ID uint `gorm:"primaryKey"`
Name string `gorm:"unique"`
Name string `gorm:"unique" json:"name"`
}